php mysql 1064_在查询中使用PHP变量时出现MySQL错误1064

session_start();

$con = mysqli_connect("localhost","root","12369","medical");

$data1 = $_SESSION["symp1"];

$data2 = $_SESSION["symp2"];

$data3 = $_SESSION["symp3"];

$data4 = $_SESSION["symp4"];

$finalData = implode(' ', array($data1, $data2, $data3, $data4));

$userinput = $_REQUEST["answer"];

$dname=$_SESSION["dname"];

$dname = str_replace(' ', '_', $dname);

echo $dname."
";

$sql = " UPDATE diseases SET UserInput = $finalData WHERE Name = $dname ";

if($userinput=='yes'){

if(mysqli_query($con,$sql)){

echo "Values inserted";

$_SESSION["info"] = "yes";

header('Location: http://localhost/medical/last.php');

}else{

echo mysqli_errno($con);

$_SESSION["info"] = "no";

//header('Location: http://localhost/medical/last.php');

}

}

?>

我收到错误1064?我已经阅读了类似问题的答案,但是我的代码不起作用.我的表架构是:

CREATE TABLE IF NOT EXISTS `diseases` (

`ID` int(50) NOT NULL AUTO_INCREMENT,

`Name` varchar(255) NOT NULL,

`Symptoms` varchar(255) NOT NULL,

`Medicines` varchar(255) NOT NULL,

`Description` varchar(255) NOT NULL,

`Tags` varchar(255) NOT NULL,

`UserInput` varchar(255) NOT NULL,

PRIMARY KEY (`ID`)

)

我的代码有什么问题?谢谢

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值