icez Posted July 9, 2010 Share Posted July 9, 2010 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 More sharing options...
AbraCadaver Posted July 9, 2010 Share Posted July 9, 2010 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'. Link to comment https://forums.phpfreaks.com/topic/207204-simple-code-wtf-is-wrong-xd/#findComment-1083349 Share on other sites More sharing options...
icez Posted July 9, 2010 Author Share Posted July 9, 2010 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 Link to comment https://forums.phpfreaks.com/topic/207204-simple-code-wtf-is-wrong-xd/#findComment-1083352 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.