这是一个非常奇怪的问题。我到处寻找解决方案。这是我的代码。它是我正在创建的网站上的帐户设置页面的一部分。该代码与用户更改他的名字有关:
// if there are post vars, user has changed something
if($_POST) {
if(isset($_POST['firstname'])) {
$firstname = trim($_POST['firstname']);
if(strlen($firstname) < 2 || strlen($firstname) > 15) {
$msg = "<span class='errmsg'>Could not complete your request. First name must be between 2 and 15 characters.</span>";
}
else {
// connect to db
require_once('modules/config.php');
// update table
$query = sprintf("UPDATE Users SET FirstName = '%s' WHERE Email = '%s'",
mysql_real_escape_string($firstname),
mysql_real_escape_string($_SESSION['email']));
mysql_query($query);
// set success message
$msg = "<span class='sucmsg'>First name successfully changed.</span>";
// reset the firstname session var
$_SESSION['firstname'] = $firstname;
}
}
}
编辑:添加了 Dagon 提到的右括号。