Php 您的SQL语法有错误;检查相应的手册

Php 您的SQL语法有错误;检查相应的手册,php,mysql,Php,Mysql,您的SQL语法有错误;请查看与MySQL服务器版本对应的手册,以了解第2行的“”附近使用的正确语法 这是我的代码怎么了 $sql = "INSERT INTO report(agent_name, date, p_title, p_fname, p_lname, p_number, address, city, state, postal_code, DoB, plan, mcn, dr_title, dr_fname, dr_lname, status, dr_npi, comment) VA

您的SQL语法有错误;请查看与MySQL服务器版本对应的手册,以了解第2行的“”附近使用的正确语法

这是我的代码怎么了

$sql = "INSERT INTO report(agent_name, date, p_title, p_fname, p_lname, p_number, address, city, state, postal_code, DoB, plan, mcn, dr_title, dr_fname, dr_lname, status, dr_npi, comment)
VALUES('$agent_name','$date','$p_title','$p_fname','$p_lname','$p_number','$address','$city','$state','$postal_code','$DoB','$plan','$mcn','$dr_title','$dr_fname','$dr_lname','$status','$dr_npi,'$comment')";

您在这里错过了一个报价
“$dr_npi,$comment”
,工作查询是

$sql = "INSERT INTO report(agent_name, date, p_title, p_fname, p_lname, p_number, address, city, state, postal_code, DoB, plan, mcn, dr_title, dr_fname, dr_lname, status, dr_npi, comment)
VALUES('$agent_name','$date','$p_title','$p_fname','$p_lname','$p_number','$address','$city','$state','$postal_code','$DoB','$plan','$mcn','$dr_title','$dr_fname','$dr_lname','$status','$dr_npi','$comment')"

如果要将SQL与PHP正确结合使用,必须将“和”组合起来


您错过了qoute
这里:
“$dr_npi,$comment”
应该是这样的:
“$dr_npi”、“$comment”


和完整的固定查询:

$sql = "INSERT INTO report(agent_name, date, p_title, p_fname, p_lname, p_number, address, city, state, postal_code, DoB, plan, mcn, dr_title, dr_fname, dr_lname, status, dr_npi, comment)
VALUES('$agent_name','$date','$p_title','$p_fname','$p_lname','$p_number','$address','$city','$state','$postal_code','$DoB','$plan','$mcn','$dr_title','$dr_fname','$dr_lname','$status','$dr_npi','$comment')";
将查询更改为:

$sql = "INSERT INTO report(agent_name, date, p_title, p_fname, p_lname, p_number, address, city, state, postal_code, DoB, plan, mcn, dr_title, dr_fname, dr_lname, status, dr_npi, comment)
VALUES('$agent_name','$date','$p_title','$p_fname','$p_lname','$p_number','$address','$city','$state','$postal_code','$DoB','$plan','$mcn','$dr_title','$dr_fname','$dr_lname','$status','$dr_npi','$comment')";

您的查询字符串末尾有一个输入错误:
“$dr_npi”、“$comment”
,与往常一样,这里的post about是相关的。Apropos:。在看到正在执行的实际SQL代码(而不是构建它的代码)之前,最好不要发布有关SQL语法错误的问题@cullen,如果问题解决了,请将答案标记为正确
$sql = "INSERT INTO report(agent_name, date, p_title, p_fname, p_lname, p_number, address, city, state, postal_code, DoB, plan, mcn, dr_title, dr_fname, dr_lname, status, dr_npi, comment)
VALUES('$agent_name','$date','$p_title','$p_fname','$p_lname','$p_number','$address','$city','$state','$postal_code','$DoB','$plan','$mcn','$dr_title','$dr_fname','$dr_lname','$status','$dr_npi','$comment')";