Update & nbsp; user & nbsp; set & nbsp; name $ _ POST [newname] [codephp] & nbsp; where & nbsp ;; and update & nbsp; user & nbsp; set & nbsp; name $ _ POST [newname] & nbsp; w quotation marks on Mysql Query operations in PHP
"update user set name='$_POST[newname][code=php]' where id=$_SESSION[id]";
And
"update user set name=$_POST[newname] where id=$_SESSION[id]";
What is the difference ?? (More and less single quotes)
This is a MySql statement for updating the user name. I asked the program to output $ sqlstr and found that the output results are the same in the above two cases,:
Today, we found that when there are no single quotes, we can update the name only when the new name is a number, with single quotes, Chinese characters and numbers are easy to use in English. if you don't know what to ask, ask for answers...
Also, I think the code written by my classmates is more complicated sometimes. it seems that I have added something like {} to the corresponding position, and I don't know how to use it ..
The next Cainiao .. Please give me a great answer .. Thank you very much ..
------ Solution --------------------
The character type must be enclosed by quotation marks-this is the most basic and questionable.
------ Solution --------------------
1. the ''of the SQL statement is used to indicate that a constant is a string.
Update user set name = 'Andy 'where id = 3
In this case, an error is reported.
Update user set name = Andy where id = 3
Depends on the type you set during table design.
2. the simpler the code, the better without affecting the function.
------ Solution --------------------
Let's take a look at the basics and practice more.
------ Solution --------------------
The characters must be enclosed in quotation marks. Numbers do not matter