I'm receiving the error above in my shopping cart application. I sell one-off items and use Paypal as the payment engine. In the remote possibility an item was previously purchased I loop through each order and update one at a time. I'm counting rows so if a record is not updated, I'd like to know. Strangely, it's working as designed (sending emai), but don't want to deploy unless I know why this error is occuring.
Here's what I've got so far. Here's the full error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in cartworks15.php on line 105.
Do I need to change the variable to a different function. Is my syntax correct.
Please let me know. Thanks in advance.
- The code:
mysql_query ($query);
// breaks the string into an array of products
$products = explode("~", $cart);
$i = 0;
// breaks each product string into its own array
foreach($products as $var => $val){
$product[$i] = explode(":", $val);
$desc = $product[$i][0];
$qty = $product[$i][1];
$money = $product[$i][2];
$pid = $product[$i][4];
$update = "UPDATE ckd_labinv SET status ='S',
sold_code = 'COD', sold_date = NOW()
WHERE pid = '$pid'
and status = 'A'";
mysql_query($update) or die(mysql_error());
$i++;
}
//echo '...Updated Database <br>';
$to = "me@test.com";
$subject = "Already Purchased Alert!";
$contents = "\nThe following item has already been purchased:\n\n * $desc \n\nThis item was purchased by the following customer:\n\n $inv_name,$email, on $date.\n";
$from_header = "From: purchasealerts@ckd.com";
$num_rows = mysql_num_rows($update); [COLOR="Red"][B]//offending line[/B][/COLOR]
//mysql_affected_rows($update);
if ($num_rows == 0)
{
mail( $to, $subject, $contents, $from_header);
echo '...sent Already Purchased Alert <br>';
}
Thanks in advance.