Here are 3 requests, for the first two I will immediately say: the second one works for me, but the first one, which is always advised, is not. The question in general is, what is the key difference between these variables in the query?

$result = mysql_query ("UPDATE $table SET $table.field=".$A." WHERE $table.field2=".$B."", $db); $result = mysql_query ("UPDATE $table SET $table.field='$A' WHERE $stable.field2='$B'", $db); $result = mysql_query ("UPDATE $table SET $table.field=$A WHERE $table.field2=$B", $db); 

Than ". $ A." different from '$ A'?

With the latter, where just $ A is clear, if there is a string variable, a space can come.

    1 answer 1

    If your $table.field field is of string type, then the value should be in single quotes, i.e. $table.field = 'сообщение' , if you write $table.field = сообщение - there will be an error.

    Double quotes are in this case read the php instruction (enclosing the string), and single quotes are part of the sql query (enclosing the value of a variable).

    But the first and third options are no different from each other, read work with strings in php.