andrewgauger Posted March 27, 2010 Share Posted March 27, 2010 put a file in your script directory named printpost.php with this code: <?php foreach ($_POST as $key => $arg){ print $key. " = ". $arg. "<br>";} ?> once you create your form, start with <form method="post" action="printpost.php"> ... </form> This will help you make sure you have the data you were expecting from the form BEFORE you start coding the handler that way you can rule out bad data as a source of unexpected results. Please reply with any good tips Quote Link to comment https://forums.phpfreaks.com/topic/196679-tip-of-the-day-printpostphp/ Share on other sites More sharing options...
greatstar00 Posted March 27, 2010 Share Posted March 27, 2010 if you experience mysql synstax error like your have an error around ...................... near " something limited 1" do this $sql="$yoursql"; echo $sql; to check whether u have the proper value in the mysql query Quote Link to comment https://forums.phpfreaks.com/topic/196679-tip-of-the-day-printpostphp/#findComment-1032622 Share on other sites More sharing options...
trq Posted March 27, 2010 Share Posted March 27, 2010 put a file in your script directory named printpost.php with this code: <?php foreach ($_POST as $key => $arg){ print $key. " = ". $arg. "<br>";} ?> once you create your form, start with <form method="post" action="printpost.php"> ... </form> This will help you make sure you have the data you were expecting from the form BEFORE you start coding the handler that way you can rule out bad data as a source of unexpected results. Please reply with any good tips Whats wrong with? <pre> <?php print_r($_REQUEST); ?> </pre> Quote Link to comment https://forums.phpfreaks.com/topic/196679-tip-of-the-day-printpostphp/#findComment-1032623 Share on other sites More sharing options...
andrewgauger Posted March 27, 2010 Author Share Posted March 27, 2010 I love the simplicity of print_r but hate the fact it doesn't break elements into individual lines.... You are right that I should be parsing the $_REQUEST variable instead, should look like: <?php foreach ($_REQUEST as $key => $arg){ print $key. " = ". $arg. "<br>";} ?> Maybe include an echo $_SERVER['HTTP_REFERER']; and execute the script with default values and print out a copy for reference. Quote Link to comment https://forums.phpfreaks.com/topic/196679-tip-of-the-day-printpostphp/#findComment-1032625 Share on other sites More sharing options...
oni-kun Posted March 27, 2010 Share Posted March 27, 2010 I love the simplicity of print_r but hate the fact it doesn't break elements into individual lines.... Oh really now? Quote Link to comment https://forums.phpfreaks.com/topic/196679-tip-of-the-day-printpostphp/#findComment-1032626 Share on other sites More sharing options...
andrewgauger Posted March 27, 2010 Author Share Posted March 27, 2010 OK, here's the thing. I use print_r for inline debugging but I think this example goes beyond that. What I am trying to achieve is a pleasing output that will help catch errors and it is my humble opinion that line delimitation is easier to catch errors in request variables and their values. Quote Link to comment https://forums.phpfreaks.com/topic/196679-tip-of-the-day-printpostphp/#findComment-1032627 Share on other sites More sharing options...
oni-kun Posted March 27, 2010 Share Posted March 27, 2010 OK, here's the thing. I use print_r for inline debugging but I think this example goes beyond that. What I am trying to achieve is a pleasing output that will help catch errors and it is my humble opinion that line delimitation is easier to catch errors in request variables and their values. It outputs newlines, thus this will work: print nl2br(print_r($_REQUEST, 1)); Anything more fancy than that in a programmers perspective is pointless. Quote Link to comment https://forums.phpfreaks.com/topic/196679-tip-of-the-day-printpostphp/#findComment-1032628 Share on other sites More sharing options...
andrewgauger Posted March 27, 2010 Author Share Posted March 27, 2010 Thanks! That was exactly the kind of formatting from print_r that I was hoping for! Quote Link to comment https://forums.phpfreaks.com/topic/196679-tip-of-the-day-printpostphp/#findComment-1032631 Share on other sites More sharing options...
trq Posted March 27, 2010 Share Posted March 27, 2010 Wraped in <pre></pre> tags as my example was, the output is quite easy to read. Quote Link to comment https://forums.phpfreaks.com/topic/196679-tip-of-the-day-printpostphp/#findComment-1032634 Share on other sites More sharing options...
andrewgauger Posted March 28, 2010 Author Share Posted March 28, 2010 Just tried it with HTML <pre> and it sure does. Nice touch. Sorry for only looking at half your solution and making inaccurate opinions based on half truth. Good show. Quote Link to comment https://forums.phpfreaks.com/topic/196679-tip-of-the-day-printpostphp/#findComment-1032879 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.