I have the following query in my php file:
if ($user) { //user is logged in (which he is)
$highscore = mysql_query("SELECT highscore FROM highscore WHERE fbID = $user"); //wil give 200
$fb_country_str = nl;
if (mysql_num_rows($highscore) == 0) { //if no result from highscore set it to 1
$highscore = 1;
} else { //if we do get a result, select the country (in this case it is: uk)
$country = mysql_query("SELECT country FROM highscore WHERE fbID = $user");
if (!($country == $fb_country_str)) { //if the country is NOT the same, update the country with $fb_country_str (which in this case it should update)
$sql = mysql_query("UPDATE highscore SET country = $fb_country_str WHERE fbID = $user");
}
}
}
Now, when run, it doesn't update the database where country uk should be changed to nl. Why not? What am I missing?
Kind regards
'
:$sql = mysql_query("UPDATE highscore SET country = '$fb_country_str' WHERE fbID = '$user'");
It will prevent the query errors, when country contains more than one word. – MarcinJuraszek 1 hour agomysql_*
functions. They are no longer maintained and community has begun the deprecation process. Instead you should learn about prepared statements and use either PDO or MySQLi. If you cannot decide, this article will help to choose. If you care to learn, here is a good PDO-related tutorial. – Esailija 56 mins ago