Php execution of mysql statement $ id = 1; & nbsp; this is OK, this execution error $ SQL = "update & nbsp; admin & nbsp; set & nbsp; pass = '$ pass1' & nbsp; where & nbsp; id = $ id; "; $ mysql = new & nbsp; MysqlHelper (); $ count php execution of mysql statements
$ Id = 1; this is OK
This execution is incorrect.
$ SQL = "update admin set pass = '$ pass1' where id = $ id ;";
$ Mysql = new MysqlHelper ();
$ Count = $ mysql-> query ($ SQL );
$ Mysql. close ();
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''at line 1
This execution is correct.
$ SQL = "update admin set pass = '$ pass1' where id = 1 ;";'
$ Mysql = new MysqlHelper ();
$ Count = $ mysql-> query ($ SQL );
$ Mysql. close ();
Share:
------ Solution --------------------
Print $ SQL.
------ Solution --------------------
Reference:
$ Id = 1; this is OK
This execution is incorrect.
$ SQL = "update admin set pass = '$ pass1' where id = $ id ;";
$ Mysql = new MysqlHelper ();
$ Count = $ mysql-> query ($ SQL );
$ Mysql. close ();
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''at line 1
This execution is correct.
$ SQL = "update admin set pass = '$ pass1' where id = 1 ;";'
$ Mysql = new MysqlHelper ();
$ Count = $ mysql-> query ($ SQL );
$ Mysql. close ();
The red part has a semicolon.
------ Solution --------------------
$ SQL = "update admin set pass = '". $ pass1. "'Where id = $ id;"; use this command.
------ Solution --------------------
2L positive solutions do not need to be added. what we talk about is the common solution to this problem: when a query encounters a problem, print the SQL statement and check it out ./
------ Solution --------------------
$pass1="123";
$id=1;
$sql="update admin set pass='".$pass1."' where id=$id;";
echo $sql;
?>
This is a real problem after testing.
------ Solution --------------------
$ SQL = "update admin set pass = '". $ pass1. "'Where id =". $ id;