我正在尝试创建一个更新数据库的表单,但它给了我一个错误。你知道它可能是什么吗? 错误:
解析错误:语法错误,意外的'$ Points'(T_VARIABLE) 第9行的D:\ 2013.1 \ xampp \ htdocs \ ranklist_get.php
welcome.html
<body>
<form action="ranklist_get.php" method="get">
Skype: <input type="text" id="Skype"><br>
Points: <input type="number" id="Points"><br>
<input type="submit">
</form>
</body>
</html>
ranklist_get.php * Abhik Chakraborty解决的代码:)
<?php
$con=mysqli_connect("localhost","root","","my_db");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_query($con,"UPDATE Persons SET Points='".$Points."' WHERE Skype='".$Skype."'");
mysqli_close($con);
?>
答案 0 :(得分:-1)
更改
mysqli_query($con,"UPDATE Persons SET Points="$Points";
WHERE Skype="$Skype"");
to
mysqli_query($con,"UPDATE Persons SET Points='".$Points."' WHERE Skype='".$Skype."'");
答案 1 :(得分:-1)
使用有效的语法。应该是
mysqli_query($con,"UPDATE Persons SET Points = '" . $Points . "' WHERE Skype = '" . $Skype . "'");