I am attempting to make my own website, from scratch, for a school project. It is going very well, and I got really far, but I encountered an issue, when comparing a variable to a number in a PHP script.
(I skipped alot of the code, which is not relevant, such as SQL connection etc)
$SQL = "INSERT INTO members (points) VALUES ('800')";
this works fine, and the number gets inserted in to my SQL databse as "int(64)"
then i put the variable in to a session in a PHP script
$_SESSION['points'] = $points[0];
then i put it down to another PHP script
$SQL = mysql_query("SELECT points FROM members WHERE username = $uname");
$points = mysql_fetch_row($SQL);
still fine, when I check $points[0] it is still 800
but I can't compare it in a statement such as this
if ($Points[0] >= 400)
{echo "took it";
}
else {echo "didnt take it";
}
Any idea of what could be wrong? It is bigger, but the variable gets threated as if its lower or empty.
$Pointsinstead of$points.mysql_*functions in new code. They are no longer maintained and are officially deprecated. See the red box? Learn about prepared statements instead, and use PDO or MySQLi - this article will help you decide which.