我是php-mysql的新手...请帮我纠正语法错误 错误是:
Parse error: syntax error, unexpected T_VARIABLE in /home/u831097172/public_html/php/update.php on line 13
第13行:
UPDATE $tbl_name SET password= '$password' WHERE email='$email';
答案 0 :(得分:3)
也许你的意思是
$query = "UPDATE $tbl_name SET password = '$password' WHERE email='$email'";
请记住在$ password和$ email变量中添加斜杠以避免sql-injection
答案 1 :(得分:1)
我认为你应该直接用陈述学习:
$mysqliConnection = new mysqli($SERVER, $USER, $PW, $TABLE);
$stmt = mysqliConnection->prepare("UPDATE ? SET password = ? WHERE email = ?");
$stmt->bind_param("sss", $tbl_name, $password, $email);
$stmt->execute();
答案 2 :(得分:0)
是否填充了变量?
也许你做得更好
$query = "UPDATE " . $tbl_name . " SET password='" . $password . "'
WHERE email='" . $email . "'";
然后你可以检查简单的是否打印出String。在那里,您可以看到您的变量是否已填满:
print_r($query);
答案 3 :(得分:-1)
你的变量$ tbl_name不在引号中$ tbl_name必须是'$ tbl_name'