Crazy problem with Delete statement

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Crazy problem with Delete statement

Post by JPlush76 »

I'm executing a block of code and what I want to do is basically if the variable matches my check I want to delete the record and display a msg. So I run a delete query and then and echo statement.

The problem is the echo statement NEVER appears unless I comment out the sql call. The record gets deleted so I know its hitting this loop correctly but the echo NEVER works. crazy.

Anyone have any thoughts?

Code: Select all

<?php
if($prod_1 == 5702 || $prod_2 == 5702)
		{
			
			$result3 = query_db("SELECT * FROM shopping_cart WHERE session_id = '".$_COOKIE['cart_id']."' AND product_id = 5702");
			$num_row3 = @mysql_num_rows($result3);
			
						
			
			if($num_row3 > 0)
			{
				echo '<BR><BR><B><font color="red">You have already used the Bergger sample promotion for item# 237281</font></B><BR>';
				$result4 = query_db("DELETE FROM shopping_cart WHERE session_id = '".$_COOKIE['cart_id']."' AND product_id = 5702");
				
			} 
			
					}
		
?>
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Re: Crazy problem with Delete statement

Post by McGruff »

That is strange... I can't see, given that the $num_row3>0 case is being called, why the echo won't work.

Commenting out the DELETE query would cut out a syntax error in that line, but then it can't be a syntax error if the DELETE query does work and you'd be getting error messages - which you're not.
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Post by JPlush76 »

actually I figured out what was happening this afternoon

damn ssl redirection and output buffering.

needless to say it was executing the code twice. so the second time there were no records so it would not echo. my boo boo :oops:
Post Reply