Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 当我尝试将表单中的信息输入到SQL时,会出现一个错误,表名重复_Php_Mysql - Fatal编程技术网

Php 当我尝试将表单中的信息输入到SQL时,会出现一个错误,表名重复

Php 当我尝试将表单中的信息输入到SQL时,会出现一个错误,表名重复,php,mysql,Php,Mysql,我制作了一个表单,可以将数据导入SQL数据库,但当我填写信息时,会出现以下错误: 错误:在andrea22_search(名称、今日日期、项目编号、区域、完成日期、HaveChangesMade、安全通道、电气设备、机械防护、校正设备、SDS、控制有毒、PPE、危险、其他危险、控制危险、监控过程、附加注释)值中插入(‘Andi’、‘2017-01-03’、‘32a’、‘AS’、‘是’、‘否’、‘是’、‘否’、‘否’、‘是’、‘否’、‘是’、‘是’、’) 表“andrea22\u搜索。andrea

我制作了一个表单,可以将数据导入SQL数据库,但当我填写信息时,会出现以下错误:

错误:在andrea22_search(名称、今日日期、项目编号、区域、完成日期、HaveChangesMade、安全通道、电气设备、机械防护、校正设备、SDS、控制有毒、PPE、危险、其他危险、控制危险、监控过程、附加注释)值中插入(‘Andi’、‘2017-01-03’、‘32a’、‘AS’、‘是’、‘否’、‘是’、‘否’、‘否’、‘是’、‘否’、‘是’、‘是’、’) 表“andrea22\u搜索。andrea22\u搜索”不存在

如果我查看submit.php文件中的代码,我看不到andrea22_search.andrea22_search的来源。这个错误当然会阻止我向数据库添加数据

$dbname = "andrea22_search";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}


$name = $_POST['input4'];
$date = $_POST['date'];
$projectnumber = $_POST['input1'];
$area   = $_POST['input2'];
$donebefore = $_POST['radio9'];
$changesmade    = $_POST['radio8'];
$safeaccess = $_POST['radio11'];
$electrical = $_POST['radio5'];
$machineguarding    = $_POST['radio6'];
$correctequipment   = $_POST['radio4'];
$sds    = $_POST['radio3'];
$controltoxic   = $_POST['radio1'];
$ppe    = $_POST['checkbox[]'];
$otherhazards   = $_POST['input3'];
$controlofhazards   = $_POST['checkbox1[]'];
$monitor    = $_POST['radio12'];
$comments   = $_POST['input'];

$sql = "INSERT INTO search (Name, TodayDate, ProjectNumber, Area, DoneBefore, HaveChangesMade, SafeAccess, ElectricalEquipment, MachineGuarding, CorrectEquipment, SDS, ControlToxic, PPE, Hazard, OtherHazard, ControlHazard, MonitorProcess, AdditionalComments) VALUES ('$name', '$date','$projectnumber','$area','$donebefore','$changesmade','$safeaccess','$electrical','$machineguarding','$correctequipment','$sds','$controltoxic','$ppe','$otherhazards','$controlofhazards','$monitor','$comments')";

if ($conn->query($sql) === TRUE) {
    echo "New record created successfully";
} else {
    echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();
?>
$dbname=“andrea22\u搜索”;
//创建连接
$conn=newmysqli($servername、$username、$password、$dbname);
//检查连接
如果($conn->connect\u错误){
die(“连接失败:”.$conn->connect\U错误);
}
$name=$_POST['input4'];
$date=$_POST['date'];
$projectnumber=$_POST['input1'];
$area=$_POST['input2'];
$donebefore=$_POST['radio9'];
$changesmade=$_POST['radio8'];
$safeaccess=$_POST['radio11'];
$electrical=$_POST['radio5'];
$machineguarding=$_POST['radio6'];
$correctequipment=$_POST['radio4'];
$sds=$_POST['radio3'];
$controltoxic=$_POST['radio1'];
$ppe=$_POST['checkbox[]'];
$otherhazards=$_POST['input3'];
$controlofhazards=$_POST['checkbox1[]';
$monitor=$_POST['radio12'];
$comments=$_POST['input'];
$sql=“在搜索中插入(名称、今日日期、项目编号、区域、DoneBefore、HaveChangesMode、安全访问、电气设备、机械防护、校正设备、SDS、控制有毒物质、PPE、危险、其他危险、控制危险、监控过程、附加注释)值(“$name”、“$date”、“$projectnumber”、“$area”、“$donebefore”、“$changesmade”、“$safeaccess”、“$electrical”、“$machineguarding”、“$corrected equipment”、“$sds”、“$controltoxic”、“$ppe”、“$otherhazards”、“$controlofhazards”、“$monitor”、“$comments”);
if($conn->query($sql)==TRUE){
echo“新记录创建成功”;
}否则{
echo“Error:”.$sql.“
”$conn->Error; } $conn->close(); ?>

我哪里出错了?

您对SQL注入持开放态度。好吧,我如何避免这一点?作为我最初问题的补充,您可以开始。代码中没有任何内容表明,
$SQL
会中途更改;您向我们展示了整个代码了吗?