Hi There All
I'm having a problem with the following code. It actually does it's job perfectly, and works, but still produces the good ol error message "Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/virtual/site35/fst/var/www/html/add.php on line 14". I'd be grateful if someone could have a quick look to see if they can discover what's wrong :-)
<?
$db = mysql_connect("localhost", "xxxxxx", "xxxxxx") or die ("Couldn't connect.");
mysql_select_db("kateskrafts_co_uk", $db) or die ("Couldn't select db.");
// create SQL statement
$sql = "SELECT IGNORE `id`, `sessid`, `itemid`, `quantity`, `type`
FROM basket WHERE `sessid`='$sessid' AND `itemid`='$itemid' AND `type`='$type' ORDER BY id";
// execute SQL query and get result
$sql_result = mysql_query($sql,$db);
// format results by row
while ($row = mysql_fetch_array($sql_result)) {
$id2 = $row[id];
$sessid2 = $row[sessid];
$itemid2 = $row[itemid];
$quantity2 = $row[quantity];
$type2 = $row[type];
if ($quantity2=="") {
// create SQL statement
$sql = "
insert into basket values ('','$sessid','$itemid','1','$type') ";
// execute SQL query and get result
$sql_result = mysql_query($sql,$db);
} else {
$quantity3 = $quantity2 + 1 ;
$sql = "UPDATE `basket` SET `quantity`='$quantity3' WHERE `sessid`='$sessid' AND `itemid`='$itemid' AND `type`='$type'";
// execute SQL query and get result
$sql_result = mysql_query($sql,$db);
}
}
?>