所以这是我的代码,不知道为什么它不工作已经看了几个小时,指向任何能够解决它的人。变量传递正常,并建立服务器连接。浏览器提供的错误消息是
您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在“用户名”附近使用正确的语法,'2011年8月20日星期六02:02:22','第一','最后','ssn'在第2行
我用变量名替换了变量数据,这样你就可以得到一个想法,所以首先说的是,浏览器实际上显示了我输入的名字。
谢谢!
$HTTP_COOKIE_VARS['username'] = $username;
$email = $_REQUEST['email'];
$Todaysdate = date('l jS \of F Y h:i:s A');
$firstname = $_REQUEST['firstname'];
$lastname = $_REQUEST['lastname'];
$ssn = $_REQUEST['ssn'];
$street = $_REQUEST['street'];
$city = $_REQUEST['city'];
$zip = $_REQUEST['zip'];
$phone1 = $_REQUEST['phone1'];
$phone2 = $_REQUEST['phone2'];
$hdhas = $_REQUEST['hdhas'];
$mi= $_REQUEST['mi'];
$query = ("INSERT INTO Members (username, email, todaysdate, firstname, lastname, ssn, street, city, zip, phone1, phone2, hdhas, mi)
VALUES('$username','$email', '$Todaysdate', '$firstname', '$lastname', '$ssn', '$street', '$city', '$zip', '$phone1', '$phone2', '$hdhas', '$mi')");
$checkuser = mysql_query("SELECT username FROM Members WHERE username='$username'");
if(mysql_num_rows($checkuser)>0)
{
mysql_query("UPDATE Members SET email='$email', username='$username', todaysdate='$Todaysdate', firstname='$firstname', lastname='$lastname', ssn='$ssn', street='$street', city='$city', zip='$zip', phone1='$phone1', phone2='$phone2', hdhas='$hdhas', mi='$mi' WHERE username = '$username'");
}
else {
mysql_query($query);
}
mysql_query($query) or die(mysql_error());
mysql_close();