简体   繁体   中英

cannot update mysql table with php

Cannot update my table with the follow code...have been trying for hours... tagboard is the table name, mytag1 is what I want to update with reference to 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);

Appreciate your help!

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

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

You have this line:

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

Try putting single quotations around the email variable too

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM