brem13 Posted May 31, 2010 Share Posted May 31, 2010 im trying to get an if statement working but it doesnt seem to want to see if the get statement is equal to something $sent = $_GET['message']; if($sent=="sent") i also tried if($_GET['message']=="sent") neither work, any suggestions? Link to comment https://forums.phpfreaks.com/topic/203436-if_get-is-equal-to-something/ Share on other sites More sharing options...
kenrbnsn Posted May 31, 2010 Share Posted May 31, 2010 Try <?php if (isset($_GET['message']) && $_GET['message'] == 'sent') { // // do something // } ?> Ken Link to comment https://forums.phpfreaks.com/topic/203436-if_get-is-equal-to-something/#findComment-1065755 Share on other sites More sharing options...
brem13 Posted May 31, 2010 Author Share Posted May 31, 2010 thank you, i tried that and still the same thing modified code to look like if (isset($_GET['message']) && $_GET['message'] == 'sent') mysql_query("DELETE FROM sent WHERE id = '$id' AND userto = '$userLoggedIn'"); else mysql_query("DELETE FROM messages WHERE id = '$id' AND userto = '$userLoggedIn'"); and the url is messages.php?id=4&message=sent&delPerm=yes Link to comment https://forums.phpfreaks.com/topic/203436-if_get-is-equal-to-something/#findComment-1065758 Share on other sites More sharing options...
kenrbnsn Posted May 31, 2010 Share Posted May 31, 2010 At the top of your script put <?php echo '<pre>' . print_r($_GET,true) . '</pre>'; ?> This will show you the $_GET array. Ken Link to comment https://forums.phpfreaks.com/topic/203436-if_get-is-equal-to-something/#findComment-1065759 Share on other sites More sharing options...
brem13 Posted May 31, 2010 Author Share Posted May 31, 2010 Array ( [id] => 4 [message] => sent [delPerm] => yes ) Link to comment https://forums.phpfreaks.com/topic/203436-if_get-is-equal-to-something/#findComment-1065761 Share on other sites More sharing options...
kenrbnsn Posted May 31, 2010 Share Posted May 31, 2010 How do you know it's not working? If you change the "if" statement to be: <?php if (isset($_GET['message']) && $_GET['message'] == 'sent') { echo "is sent<br>\n"; } else { echo "is NOT sent<br>\n"; } ?> What is display? Ken Link to comment https://forums.phpfreaks.com/topic/203436-if_get-is-equal-to-something/#findComment-1065762 Share on other sites More sharing options...
brem13 Posted May 31, 2010 Author Share Posted May 31, 2010 ok, it worked, i had my select statement trying to delete from the wrong field, sorry, and thanks again! Link to comment https://forums.phpfreaks.com/topic/203436-if_get-is-equal-to-something/#findComment-1065768 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.