UPDATE语句不起作用,但适用于phpMyAdmin和live host

I have this update statement below:

string_from_base64_encode_ends_with = base64_encode(serialize($_POST));

UPDATE members SET settings = 'string_from_base64_encode_ends_with=='
WHERE email = "right@emailhere.com" AND active=1
  1. (localhost) When I process with mysql_query(), the real record is not updated, although mysql_affected_rows() returns 1

  2. (localhost) But when I copy this UPDATE statement then process through phpMyAdmin; it works, mysql_affected_rows() returns 1 & real record really updated

  3. (live host) With these codes, no change, when I run on a live host; all are very good: record updated, mysql_affected_rows() returns 1

May you help me find out there something wrong with MySQL server? Or some thing else?

Many thanks

PS: all other UPDATE statements are still fine on both localhost & live host, updated; this statement is problem only

You need to escape the string using mysql_real_escape_string()

$string = mysql_real_escape_string("string_from_base64_encode_ends_with==");
 mysql_query("UPDATE members SET settings = '".string ."' WHERE email = \"right@emailhere.com\" AND active=1");