I have the following code used on a php page, I am at the point of just trying to get it to work, it runs the first query fine(which is an insert) and returns the correct value to $orderid
But it will not return anything for the select query next, if I take out the variable $myorderid and put in a number it will return the expected results, but as soon as I try to use a variable it returns nothing.
I have tried using mysql_escape_string, sprintf and now the intval methods but nothing seems to work.
No error is returned from mysql just an empty result set.
mysql_query($sSQL) or print(mysql_error());
$orderid = mysql_insert_id();
$myorderid = $orderid;
$myquery = "SELECT cartOrderID, Sum(pDonationAmt) as amount
FROM products INNER JOIN cart ON ( cartProdID = pID )
WHERE cartOrderID = " . intval($myorderid). " GROUP BY cartOrderID ";
$myresults = mysql_query($myquery);
while ($row = mysql_fetch_assoc($myresults))
{ error_log('orderid inserted is:.$orderid.' OrderID in mysql:'.$row['cartOrderID'].' and the total is: '.$row['amount'], 3, 'inc/atestingdata.txt'); }
Thanks for any help with this!
The old ‘echo’ can help … try: