A small question about the combination of SQL statements in the single-entry registration module: a registration class written in single-entry mode
$ Uname = $ _ POST ['uname'];
$ Pwd = md5 ($ _ POST ['pwd']);
// Combined SQL
$ SQL = "insert into user (username, password) values ($ uname, $ pwd )";
M ()-> exec ($ SQL );
$ SQL has a problem with inserting data. $ uname and $ pwd both get the value. which one I wrote is wrong. isn't double quotation marks directly capable of parsing variables?
// I changed this to direct insertion. No problem $ SQL = "insert into user (username, password) values ('xiaozhang', '123 ')";
$ SQL I changed to $ SQL = "insert into user (username, password) values (". $ uname. ",". $ pwd. ")"; no. what should I do if something goes wrong.
Reply to discussion (solution)
My debugging method is to write an insert statement in the database first. after the execution is successful, you can piece together the expressions on the php side according to the statements you have written.
$ SQL = "insert into user (username, password) values ('$ uname',' $ pwd ')";
Strings must be enclosed in quotation marks. Otherwise, they will be misunderstood.
$ SQL = "insert into user (username, password) values ('". $ uname. "','". $ pwd. "')"; when an error occurs, you can view the SQL output.
$ SQL = "insert into user (username, password) values ('$ uname',' $ pwd ')";
Strings must be enclosed in quotation marks. Otherwise, they will be misunderstood.
$ Uname is not a variable. why is it enclosed in single quotes? isn't single quotes in php not a variable not parsed?
$ SQL = "insert into user (username, password) values ('$ uname',' $ pwd ')";
Strings must be enclosed in quotation marks. Otherwise, they will be misunderstood.
$ Uname is not a variable. why is it enclosed in single quotes? isn't single quotes in php not a variable not parsed?
If your uname is defined as varchar without quotation marks, the SQL statement will report an error.
$ SQL = "insert into user (username, password) values ('$ uname',' $ pwd ')";
Strings must be enclosed in quotation marks. Otherwise, they will be misunderstood.
$ Uname is not a variable. why is it enclosed in single quotes? isn't single quotes in php not a variable not parsed?
If your uname is defined as varchar without quotation marks, the SQL statement will report an error.
My database defines the char (20) type