I am trying to select a value in php, however, it always returns the value 4. However, if I change the select statement to any other column (even in another table) it keeps returning the standard value 4. What is wrong with my code?
$change = mysql_query("SELECT CurrentChange FROM tbrates WHERE pID = 50");
$res = $change *= 10;
echo($res);
mysql_query doesn't return a result, just a resource to use with a mysql_fetch function
$query = "SELECT CurrentChange FROM tbrates WHERE pID = 50";
$result = mysql_query($query) or die("Error on ".__FILE__ ." line: ".__LINE__ ."<br/>". $query.'<br />'.mysql_error());
list($change)=mysql_fetch_row($result);
$res= $change *= 10;
echo($res);
You may be looking for this:
$change = mysql_query("SELECT (CurrentChange * 10) as CurrentChange FROM tbrates WHERE pID = 50");
$res = mysql_fetch_result($change) ;
echo($res);