Hi,
I have a query in my php file that when run outside of PHP works fine and returns the result (MySQL) but from within the php file it does not produce any result.
$query = "SELECT SUM(Qty) AS opt_count FROM OrderDetails INNER JOIN Orders
ON Orders.TrackingNumber = OrderDetails.TrackingNumber
WHERE OrderDetails.OptionNumber = '$option_number' AND Orders.BuilderID = '$builderid'
GROUP BY OptionNumber";
The above works fine when I test it with PHPMyAdmin (after replacing the variable names with values, of course). It gives me a 1x1 table with the heading "opt_count" and a value of 11.
But:
$res = mysql_query($query);
$num_rows = mysql_num_rows($res);
//$n = mysql_result($res, 0, 'opt_count');
$row = mysql_fetch_array($res);
$n = $row['opt_count'];
results in:
n=
num_rows=0
Thanx.