我无法理解为什么xampp会给我一个错误
解析错误:语法错误,意外''(T_ENCAPSED_AND_WHITESPACE),期望标识符(T_STRING)或变量(T_VARIABLE)或数字(T_NUM_STRING)在第31行的C:\ xampp \ htdocs \ Permanent \ edstul.php
第31行是:
if($_POST){
//update the record if the form was submitted
$sql="UPDATE users SET pass='$_POST['pass']',fname='$_POST['fname']',lname='$_POST['lname']',mi='$_POST['mi']',age='$_POST['age']',course='$_POST['course']',yearlevel='$_POST['yearlevel']'
WHERE id=" . mysql_real_escape_string($_POST['id']);
if(mysql_query($sql)){
//this will be displayed when the query was successful
echo "<div>Record was edited.</div>";
}else{
die("SQL: " . $sql . " >> ERROR: " . mysql_error());
}
}
我无法理解。我真的很讨厌声明sql语法,因为它没有调试。
答案 0 :(得分:1)
你有一些PHP连接错误,试试这个:
$sql="UPDATE users SET pass='". $_POST['pass'] . "',
fname='" . $_POST['fname'] . "',
lname='" . $_POST['lname'] . "',
mi='" . $_POST['mi'] . "',
age='" . $_POST['age'] . "',
course='" . $_POST['course'] . "',
yearlevel='" . $_POST['yearlevel'] . "'
WHERE id=" . mysql_real_escape_string($_POST['id']);