Jump to content

Simple code - WTF is wrong xD??


icez

Recommended Posts

Hey guys... Personally, I really don't know what is wrong with this... my script print me : You are not subscribe, when yes I am! and if I go to the delete part (index.php?p=unsubscribe&[email protected]&delete) My script do nothing...

 

 

<?php
if(isset($_GET['mail']))
{
	$mailListing = mysql_query("SELECT * FROM mailList WHERE mail=`".$_GET['mail']."`") or print('You are not subscribe');
	$mail = mysql_num_rows($mailListing);

	if($mail > 0)
	{
		echo '<a href="index.php?p=unsubscribe&mail='.$_GET['mail'].'&delete" onclick="return confirm(\'Are you sure?\');">Remove me from Mailing List.</a>';

		if(isset($_GET['delete']))
		{
				mysql_query("DELETE FROM mailList WHERE mail=`".$_GET['mail']."`") or die(mysql_error());
		}
	}

}
?>

Link to comment
https://forums.phpfreaks.com/topic/207204-simple-code-wtf-is-wrong-xd/
Share on other sites

You don't want that  message after the query.  It should be an if after you have fetched a row and check it.  Also, the query failed because you have ticks ` around the value instead of quotes so it printed the message.  Queries don't fail because no rows were returned.  They fail because of an error.  Do the query and if it fails display the mysql_error().  Then check if rows were returned mysql_num_rows().  If not, then 'You are not subscribe'.

You don't want that  message after the query.  It should be an if after you have fetched a row and check it.  Also, the query failed because you have ticks ` around the value instead of quotes so it printed the message.  Queries don't fail because no rows were returned.  They fail because of an error.  Do the query and if it fails display the mysql_error().  Then check if rows were returned mysql_num_rows().  If not, then 'You are not subscribe'.

 

Ok.. yeah.. lost 20 minutes of my times because of this little F******* thing: `` '' -.-

 

BTW : Thank you xD

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.