Can run code
All UsersAdd user
"; for ($i =1; $i < $dataCount; $i + +) { $result _arr=mysql_fetch_assoc ($result); $id = $result _arr[' id ']; $name = $result _arr[' name ']; $age = $result _arr[' age '); echo "$id $name$age ' > Modify
' > Delete ';} echo "";? >
The return value of mysql_query in two pieces of code, but why a function has a warning when it calls its return value
Reply to discussion (solution)
"SELECT * from users WHERE name= $name and password= $password"
The above code is problematic, name and password are not quoted, resulting in a SQL syntax error, no return to the resource type, and a Boolean value of False
The correct code should be
"SELECT * from Users WHERE ' name ' = $name and ' password ' = $password"
$sql = "SELECT * from users WHERE name= $name and password= $password";
Switch
$sql = "SELECT * from Users WHERE name= '". $name. "' and password= ' ". $password." ";
Because you $name, $password if empty, it can cause a syntax error.
Or is it wrong? To try to change the SQL statement again, it should be that $name and $password are not treated as strings causing an error ...
"SELECT * from Users WHERE ' name ' =". $name. " and ' password ' = ". $password
Or is it wrong? To try to change the SQL statement again, it should be that $name and $password are not treated as strings causing an error ...
"SELECT * from Users WHERE ' name ' =". $name. " and ' password ' = ". $password
I wrote it wrong again ... That should be it."SELECT * from Users WHERE name= '". $name. "' and password= ' ". $password." ";
Or is it wrong? To try to change the SQL statement again, it should be that $name and $password are not treated as strings causing an error ...
"SELECT * from Users WHERE ' name ' =". $name. " and ' password ' = ". $password
I wrote it wrong again ... That should be it."SELECT * from Users WHERE name= '". $name. "' and password= ' ". $password." ";
Can you tell me why
$sql = "SELECT * from users WHERE name= $name and password= $password";
Switch
$sql = "SELECT * from Users WHERE name= '". $name. "' and password= ' ". $password." ";
Because you $name, $password if empty, it can cause a syntax error.
Can you tell me why?
Or is it wrong? To try to change the SQL statement again, it should be that $name and $password are not treated as strings causing an error ...
"SELECT * from Users WHERE ' name ' =". $name. " and ' password ' = ". $password
I wrote it wrong again ... That should be it."SELECT * from Users WHERE name= '". $name. "' and password= ' ". $password." ";
Can you tell me why
Because $name and $password should appear as strings in SQL statements (that is, single quotes wrap up $name and $password values)
Or do you want to know why you want to do that? Single and double quotes?
Or is it wrong? To try to change the SQL statement again, it should be that $name and $password are not treated as strings causing an error ...
"SELECT * from Users WHERE ' name ' =". $name. " and ' password ' = ". $password
I wrote it wrong again ... That should be it."SELECT * from Users WHERE name= '". $name. "' and password= ' ". $password." ";
Can you tell me why
Because $name and $password should appear as strings in SQL statements (that is, single quotes wrap up $name and $password values)
Or do you want to know why you want to do that? Single and double quotes?I'd like to know why I'm stitching single and double quotes and why we have to put variables in the. The middle of the two points is what the role of $sql = "SELECT * from users WHERE name= $name and password= $password";
If the $name and $password variables are numeric, you can use them directly in SQL statements, and if you are a variable of type string, you need to add single quotes
I split the code into three paragraphs, and you should be able to understand. The two point is used to concatenate strings, meaning to tell PHP that the variable after the point is a string
"SELECT * from Users WHERE name= '"
"' and password= '"
"'"
That is, when each single quote/double quote touches the second single quotation mark/double quote, that segment of the character ends. These three paragraphs are all in a double quote parcel quotation mark.
I split the code into three paragraphs, and you should be able to understand. The two point is used to concatenate strings, meaning to tell PHP that the variable after the point is a string
"SELECT * from Users WHERE name= '"
"' and password= '"
"'"
That is, when each single quote/double quote touches the second single quotation mark/double quote, that segment of the character ends. These three paragraphs are all in a double quote parcel quotation mark.Yes, thank you.