Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete rows and cookies problem

Status
Not open for further replies.

mancroft

Programmer
Joined
Oct 26, 2002
Messages
267
Location
GB
I am doing a shopping cart (still!) and have a ThankYou.php which sends out details of the order to the shop.

That part works!!

At the end of this, I want to delete the items (rows) from the database and the cookie.

However, the code below gives:

outSIDE Delete failed.

Any ideas, please?

I really appreciate all the help that I have had with this cart and this is just about the last problem to solve!

Thanks.

Code:
echo "outSIDE";

$result = mysql_query("delete from cart where cookieId = '" . GetCartId() . "' and cartId = $cartId",$con);

echo $result; 

//checks query result
if ($result === false) die("Delete failed."); 

while($row = mysql_fetch_row($result)){

$res=mysql_query($result) or die(mysql_error());

echo $res; 

}

//delete cookie
setcookie("cartId", session_id(), time() - 9999);
setcookie("cartId", session_id());
setcookie("cartId");
 
I've been watching your posts over the last couple of days. Many people have given you valuable information but it seems that you don't use it.

There's a reason why you are advised to assemble your SQL statement outside of the actual query statement.
There's a reason that error checking should be added to every mysql_query() statement.
Have you read about the nature of $result as returned from mysql_query()?

sleipnir214's FAQ about debugging code gives the basic tools to debug. If you follow the FAQ and the given information you should be able to solve this by yourself. It is not different from the previous questions and your code hasn't adopted much of the suggested improvements.

You may think this is a mean post, but I strongly believe it is for your own benefit to get behind the concepts and be able to understand them fully so you can become independent coder. You don't need rely on the forum members to solve the same problems multiple times.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top