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"]; ?> Quote Link to comment Share on other sites More sharing options...
PaulRyan Posted April 9, 2013 Share Posted April 9, 2013 (edited) <?PHP $x = isset($_POST['x']) ? trim($_POST['x']) : FALSE; ?> Edited April 9, 2013 by PaulRyan Quote Link to comment Share on other sites More sharing options...
Q695 Posted April 9, 2013 Author Share Posted April 9, 2013 (edited) 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? Edited April 9, 2013 by Q695 Quote Link to comment Share on other sites More sharing options...
Q695 Posted April 9, 2013 Author Share Posted April 9, 2013 (edited) Not sure what the error was, but when I coppied, and pasted from here it became solved without the isset. Edited April 9, 2013 by Q695 Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Q695 Posted April 9, 2013 Author Share Posted April 9, 2013 (edited) When there is a 0 returned, it treats it like false, not like data is being returned. Edited April 9, 2013 by Q695 Quote Link to comment Share on other sites More sharing options...
Solution Q695 Posted April 10, 2013 Author Solution 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 ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.