Q695 Posted April 9, 2013 Share Posted April 9, 2013 Why are these errors comming from a $_POST variable loader when the post is blank, but solved when it's filled? ( ! ) Notice: Undefined index: x in xxxxxxxxxxxxxxxx on line 6 Call Stack # Time Memory Function Location 1 0.0025 711336 {main}( ) ..\index.php:0 2 0.0205 751136 include( 'xxxxxxxxxxxxxxxx' ) ..\index.php:113 <?php $x=$_POST["x"]; ?> Link to comment https://forums.phpfreaks.com/topic/276706-a-little-rusty-after-time-away-post-error/ Share on other sites More sharing options...
PaulRyan Posted April 9, 2013 Share Posted April 9, 2013 <?PHP $x = isset($_POST['x']) ? trim($_POST['x']) : FALSE; ?> Link to comment https://forums.phpfreaks.com/topic/276706-a-little-rusty-after-time-away-post-error/#findComment-1423652 Share on other sites More sharing options...
Q695 Posted April 9, 2013 Author Share Posted April 9, 2013 Oh, you need to do an isset check just to see if a variable is being passed when there isn't one. When did that change? Link to comment https://forums.phpfreaks.com/topic/276706-a-little-rusty-after-time-away-post-error/#findComment-1423810 Share on other sites More sharing options...
Q695 Posted April 9, 2013 Author Share Posted April 9, 2013 Not sure what the error was, but when I coppied, and pasted from here it became solved without the isset. Link to comment https://forums.phpfreaks.com/topic/276706-a-little-rusty-after-time-away-post-error/#findComment-1423811 Share on other sites More sharing options...
jcbones Posted April 9, 2013 Share Posted April 9, 2013 Its always been there, but since it is a notice, most production servers hide the error. empty will also work. Link to comment https://forums.phpfreaks.com/topic/276706-a-little-rusty-after-time-away-post-error/#findComment-1423815 Share on other sites More sharing options...
Q695 Posted April 9, 2013 Author Share Posted April 9, 2013 When there is a 0 returned, it treats it like false, not like data is being returned. Link to comment https://forums.phpfreaks.com/topic/276706-a-little-rusty-after-time-away-post-error/#findComment-1423822 Share on other sites More sharing options...
Q695 Posted April 10, 2013 Author Share Posted April 10, 2013 Got it <?php if (isset($_POST['x']) || isset($_POST['xx']) || isset($_POST['xxx'])){ $x = $_POST['x']; $xx = $_POST['xx']; $xxx = $_POST['xxx']; //actions ?> Link to comment https://forums.phpfreaks.com/topic/276706-a-little-rusty-after-time-away-post-error/#findComment-1423855 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.