【问题标题】:Parse error: syntax error, unexpected '$Points' (T_VARIABLE) [closed]解析错误:语法错误,意外的“$Points”(T_VARIABLE)[关闭]
【发布时间】:2014-02-17 03:20:11
【问题描述】:

我正在尝试制作一个更新数据库的表单,但它给了我一个错误。你知道它可能来自什么吗? 错误:

解析错误:语法错误,意外的'$Points' (T_VARIABLE) in D:\2013.1\xampp\htdocs\ranklist_get.php 第 9 行

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);
?>

【问题讨论】:

  • 这个问题是由无法再重现的问题简单的印刷错误引起的。虽然类似的问题可能是这里的主题,但这个问题的解决方式不太可能帮助未来的读者。这通常可以通过在发布之前识别并仔细检查the shortest program necessary to reproduce the problem 来避免。

标签: php parsing parse-error php-parse-error


【解决方案1】:

改变

mysqli_query($con,"UPDATE Persons SET Points="$Points";
WHERE Skype="$Skype""); 

to 

mysqli_query($con,"UPDATE Persons SET Points='".$Points."' WHERE Skype='".$Skype."'");

【讨论】:

  • Thanx,但现在它给了我这些错误注意:未定义的变量:第 9 行的 D:\2013.1\xampp\htdocs\ranklist_get.php 中的点注意:未定义的变量:D:\2013.1 中的 Skype \xampp\htdocs\ranklist_get.php 第 9 行
  • 在 sql 中使用之前如何获取值?
  • 值在welcome.html中输入,然后通过ranklist_get.php在sql数据库中更新
【解决方案2】:

使用有效的语法。应该是的

mysqli_query($con,"UPDATE Persons SET Points = '" . $Points . "' WHERE Skype = '" . $Skype . "'");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-05-11
    • 2013-03-10
    • 2012-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-26
    相关资源
    最近更新 更多