开发者

Syntax error in php

Im trying to get this query to work but i cant get the syntax right, can someone help? Thanks

 $query="UPDATE users SET upsell2=开发者_如何学运维'" .$upsell2.
          "' upsell1='" .$upsell1."' WHERE email='" .$email."'";


You're missing a comma between the two "set" columns:

 $query="UPDATE users SET upsell2='" .$upsell2.
      // add comma here.
      "', upsell1='" .$upsell1."' WHERE email='" .$email."'";


 $query="UPDATE users SET upsell2='$upsell2', upsell1='$upsell1' WHERE email='$email'";

You don't have to do string concatenation if you are just populating the string with data from vars. Hovewer, using vars in plain SQL is a very bad idea, consider using prepared statements


$query = "UPDATE users SET upsell2='" . $upsell2 .
"', upsell1='" . $upsell1 . "' WHERE email='" . $email. "'";

Note the comma on the second line, are you sure it is a PHP syntax error and not a SQL syntax error?


Looks like you are missing a comma between fields

$query="UPDATE users SET upsell2='" .$upsell2."', upsell1='", .$upsell1."' WHERE email='" .$email."'";


And don't forget to escape the values (for MySQLi it's mysqli_real_escape_string function) to prevent possible errors caused by unescaped data.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜