无法用php更新mysql表

时间:2013-10-10 19:24:41

标签: php mysql

无法使用以下代码更新我的表...已经尝试了几个小时...... tagboard 是表格名称, mytag1 是我想要参考 emailadd 更新的内容。

$myemail = mysql_real_escape_string( $_POST["myemail"] );
$mytag1 = mysql_real_escape_string( $_POST["mytag1"] );
echo $mytag1;
$query = "UPDATE tagboard SET mytag1='{$mytag1}' WHERE emailadd = {$myemail}";
$result=mysql_query($query);

OR

$sql="UPDATE tagboard SET mytag1 ='".$_POST['mytag1']."' WHERE  myemail='".$_POST['myemail']."'";
$result=mysql_query($sql);

感谢您的帮助!

2 个答案:

答案 0 :(得分:0)

在查询中的电子邮件地址字段周围添加引号:

$query = "UPDATE tagboard SET mytag1='{$mytag1}' WHERE emailadd = '{$myemail}'";

答案 1 :(得分:0)

你有这一行:

$query = "UPDATE tagboard SET mytag1='{$mytag1}' WHERE emailadd = {$myemail}";

尝试在电子邮件变量周围添加单引号

$query = "UPDATE tagboard SET mytag1='{$mytag1}' WHERE emailadd = '{$myemail}'";