Hi, I have this weird problem where PHP5 is not retrieving ints from a MySql database. This is the code I have:
$db = mysql_connect('XX.XX.XX.XX', 'DBName', 'DBPwd');
$query = 'Select * FROM Users WHERE UserName = \'Carlo\'';
$result = mysql_query($query);
if(!$result)
{
echo 'Could not successfuly run query: '.mysql_error();
exit;
}
if(mysql_num_rows($result) == 0)
{
echo '0 results';
}
$row = mysql_fetch_assoc($result);
echo 'UserId: '.$row['UserId']; // THIS IS THE INT VALUE FROM THE DATABASE
echo 'UserName: '.$row['UserName']; // THIS IS A STRING VALUE FROM THE DATABASE
mysql_close($db);
The code prints:
UserId:
UserName: Carlo
Any suggestion is greatly appreciated!