Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.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 在数据库中插入时出错_Php_Mysql - Fatal编程技术网

Php 在数据库中插入时出错

Php 在数据库中插入时出错,php,mysql,Php,Mysql,我试图在数据库中插入值,但出现以下错误 Error: insert into lead (Name,phone,dob,height,weight,source,city,area,address,status,preferred_mode_of_contact,email,email_verified,style,number_of_classes_per_week,days_of_week,time_start,time_end,duration,start_date,description

我试图在数据库中插入值,但出现以下错误

Error: insert into lead (Name,phone,dob,height,weight,source,city,area,address,status,preferred_mode_of_contact,email,email_verified,style,number_of_classes_per_week,days_of_week,time_start,time_end,duration,start_date,description,preferred_trainer_type,price_per_class,price_per_month,call) value ('','','','','','Source 1','','','','','phone','','0','','1','0','','','','','','','','','2015-07-16')
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'call) value ('','','','','','Source 1','','','','','phone','','0','','1','0',''' at line 1
我已检查是否传递了正确数量的值无额外列无额外值。列“call”为日期数据类型。当我从插入查询中删除“call”时,它工作正常

下面是查询

$sql="insert into lead (Name,phone,dob,height,weight,source,city,area,address,status,preferred_mode_of_contact,email,email_verified,style,number_of_classes_per_week,days_of_week,time_start,time_end,duration,start_date,description,preferred_trainer_type,price_per_class,price_per_month,call)
value ('$name','$phone','".$dob."','$Height','$Weight','$Source','$City','$Area','$Address','$Status','$preferred_mode_of_con','$email','$email_verify','$style','$noc','$day','$time_from','$time_to','$duration','".$ts."','$des','$ptt','$price','$price_month','".$call."')";

if (mysqli_query($conn, $sql))
        echo "User registered Sucessfully";
    else
        echo "Error: " . $sql . "<br>" . mysqli_error($conn);
            echo '<br><a href="lead_reg.php">Click Here to go back</a></h3>';
$sql=“插入潜在客户(姓名、电话、出生日期、身高、体重、来源、城市、地区、地址、状态、首选联系人模式、电子邮件、电子邮件验证、风格、每周课程数、每周天数、开始时间、结束时间、持续时间、开始日期、描述、首选培训师类型、每班价格、每月价格、电话)
值(“$name”、“$phone”、“$dob”、“$Height”、“$Weight”、“$Source”、“$City”、“$Area”、“$Address”、“$Status”、“$preferred\u mode\u of the u con”、“$email\u verify”、“$style”、“$noc”、“$day”、“$time\u from”、“$time\u-to”、“$time\u-to”、“$duration”、“$ts”、“$des”、“$ptt”、“$price”、$ptt'、“$price”、$call”、“$month”;”;
if(mysqli_查询($conn,$sql))
echo“用户注册成功”;
其他的
echo“Error:”.$sql.
“.mysqli_Error($conn); 回声“
”;
我修改了您的sql。在您的sql中,问题是调用。它会工作的

$sql="insert into lead (Name,phone,dob,height,weight,source,city,area,address,status,preferred_mode_of_contact,email,email_verified,style,number_of_classes_per_week,days_of_week,time_start,time_end,duration,start_date,description,preferred_trainer_type,price_per_class,price_per_month,`call`)
values ('$name','$phone','".$dob."','$Height','$Weight','$Source','$City','$Area','$Address','$Status','$preferred_mode_of_con','$email','$email_verify','$style','$noc','$day','$time_from','$time_to','$duration','".$ts."','$des','$ptt','$price','$price_month','".$call."')";

谢谢

我修改了你的sql。在你的sql中,问题是调用。它会工作的

$sql="insert into lead (Name,phone,dob,height,weight,source,city,area,address,status,preferred_mode_of_contact,email,email_verified,style,number_of_classes_per_week,days_of_week,time_start,time_end,duration,start_date,description,preferred_trainer_type,price_per_class,price_per_month,`call`)
values ('$name','$phone','".$dob."','$Height','$Weight','$Source','$City','$Area','$Address','$Status','$preferred_mode_of_con','$email','$email_verify','$style','$noc','$day','$time_from','$time_to','$duration','".$ts."','$des','$ptt','$price','$price_month','".$call."')";
谢谢

因为是保留字,如果要将其用作列名,需要将其括在反引号(`)中。这是查询的正确形式:

$sql="insert into lead (Name,phone,dob,height,weight,source,city,area,address,status,preferred_mode_of_contact,email,email_verified,style,number_of_classes_per_week,days_of_week,time_start,time_end,duration,start_date,description,preferred_trainer_type,price_per_class,price_per_month,`call`) ".
     "value ('$name','$phone','".$dob."','$Height','$Weight','$Source','$City','$Area','$Address','$Status','$preferred_mode_of_con','$email','$email_verify','$style','$noc','$day','$time_from','$time_to','$duration','".$ts."','$des','$ptt','$price','$price_month','".$call."')";
另外,我不知道你为什么要用不同的方式对待某些变量,如
$dob
。你可以使用与
$name

相同的语法,因为它是一个保留字,如果你想将它用作列名,你需要将它括在反引号(`)中。这是正确的查询形式:

$sql="insert into lead (Name,phone,dob,height,weight,source,city,area,address,status,preferred_mode_of_contact,email,email_verified,style,number_of_classes_per_week,days_of_week,time_start,time_end,duration,start_date,description,preferred_trainer_type,price_per_class,price_per_month,`call`) ".
     "value ('$name','$phone','".$dob."','$Height','$Weight','$Source','$City','$Area','$Address','$Status','$preferred_mode_of_con','$email','$email_verify','$style','$noc','$day','$time_from','$time_to','$duration','".$ts."','$des','$ptt','$price','$price_month','".$call."')";

另外,我不知道你为什么要用不同的方式对待某些变量,比如
$dob
。你可以使用与
$name

相同的语法来处理什么
var\u dump($call);
输出?这个代码的可能重复可能有潜在的味道。什么
var\u dump($call)5944。