I am currently performing a job that needs to access the database, and I had a lot of difficulty in some queries , including the query of UPDATE
. But after much searching I found a solution and wanted to ask what the difference is, which is better, etc.
I used
$sql = mysql_query("UPDATE tabela SET campo1 = ' ".$1." ', campo2 = ' ".$2." ' WHERE user = ' " .$3. " ');
But what worked was:
$sql = mysql_query("UPDATE tabela SET campo1 = '$1', campo2 = '$2' WHERE user=$3");
In other words, I removed endpoints, quotation marks, etc. Does it make any difference? I used with the dots and quotation marks in queries of type SELECT
and INSERT
and it worked.