yshua Posted November 7, 2013 Share Posted November 7, 2013 Dear PHP and MySQL people: Am using Apache2.2.17, PHP5.3.8, MySQL5.1.65, phpmyadmin3.5.3, Win7 with the following code: <?php session_start(); include("includes/db.php"); $submitform = 0; if(!empty($_POST)){ $submitform = 1; $query = "INSERT INTO usrtable (firstname,lastname,phone,emailid,howhear) VALUES ('".$_REQUEST['firstname']."', '".$_REQUEST['lastname']."', '".$_REQUEST['phone']."', '".$_REQUEST['emailid']."', '".mysql_real_escape_string($_REQUEST['howhear'])."')"; if (mysql_query($query) === TRUE) { $_SESSION['seqno'] = mysql_insert_id(); $_SESSION['user'] = $_POST['firstname']; $_SESSION['emailid'] = $_REQUEST['emailid']; }else{ header('Location: form.php?errormsg=Insert Error.'.mysql_error()); #die("Error! Insert failed.Please try again"); } mysql_close($mysql); } if($submitform == 1) { ?> <html> <body onLoad="document.myform.submit();"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <table width="843" height="102" align="center" bgcolor="#F7F7F7"> <tr> <td width="573" height="104"><img src="images/mysite.bmp" border="0"> </td> </tr> <tr> <td height="53" valign="center"> <table width="799" height="185" align="center"></td> </tr> <tr><td height="179" valign="top"><h2 align="center"> <h2><strong>My Site Heading!!</strong></h2> </td> </tr> <input type="hidden" name="cmd" value="_s-xclick"> <input type="hidden" name="hosted_button_id" value="1111111111111"> <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!"> <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="800" height="1" valign="center"> </table> <input type="hidden" name="charset" value="UTF-8"> <input type="hidden" name="return" value="https://www.mysite.com/finish.php"> <input type="hidden" name="rm" value="1"> <input type="hidden" name="cancel_return" value="https://www.mysite.com/thisscreen/unhook.php"> </form> </body> </html> <?php } else{ header('Location: form.php'); } ?> Can anyone see what might prevent the line insert which had been working before...? Completely at a loss, Yshua Quote Link to comment https://forums.phpfreaks.com/topic/283693-somehow-the-insert-from-form-is-failing-wout-error-message/ Share on other sites More sharing options...
dalecosp Posted November 7, 2013 Share Posted November 7, 2013 Not really. Perhaps corrupt/unexpected input? That's often why something that has been working quits (if you haven't made changes) --- because you forgot to account for some edge case/funky character input. Quote Link to comment https://forums.phpfreaks.com/topic/283693-somehow-the-insert-from-form-is-failing-wout-error-message/#findComment-1457447 Share on other sites More sharing options...
yshua Posted November 7, 2013 Author Share Posted November 7, 2013 (edited) Thanks, Dale, Am sorry about the lack of clarity, some typo MAY have been inserted in the php code of other code files. Will reverify your theory, but so far, in this testing phase, the input has also all been pristine and expected! Repeatedly, as in 10 attempts by myself, it fails to insert.... But perhaps some little script warning has caused this. Still looking, Yshua Edited November 7, 2013 by yshua Quote Link to comment https://forums.phpfreaks.com/topic/283693-somehow-the-insert-from-form-is-failing-wout-error-message/#findComment-1457455 Share on other sites More sharing options...
mac_gyver Posted November 7, 2013 Share Posted November 7, 2013 (edited) what exact execution path or symptom are you getting? do you have php's error_reporting set to E_ALL and either display_errors set to ON or log_errors set to ON so that any php detected errors will be reported? do you have output_buffering turned OFF in your php.ini so that things you or php might display on a page aren't discarded when you do a header() redirect? edit: do you know for a fact that the code where your query is at is even being executed? Edited November 7, 2013 by mac_gyver Quote Link to comment https://forums.phpfreaks.com/topic/283693-somehow-the-insert-from-form-is-failing-wout-error-message/#findComment-1457457 Share on other sites More sharing options...
yshua Posted November 12, 2013 Author Share Posted November 12, 2013 Dear Mac_gyver: Please forgive how late this reply arrived. Have been fighting home front only somewhat successfully. The error reporting is THE most disappointing function of my PHP at this time! Good that you brought that up. The most infuriating is that the old "access.log" and "error.log" has somehow been bypassed with a new "sitename.com-access.log" and "sitename.com-error.log," both of which have these bulky dumps interspersed, taking up a huge amount of space, and making the logs practically impossible to read/decipher.... But you have given me much to go on! Am hoping and praying for quick insights. Yshua Quote Link to comment https://forums.phpfreaks.com/topic/283693-somehow-the-insert-from-form-is-failing-wout-error-message/#findComment-1458025 Share on other sites More sharing options...
dalecosp Posted November 12, 2013 Share Posted November 12, 2013 If you have access to php.ini, you can set something like: error_log = /some/path/you/can/read/php_error_log and get only PHP errors written here. Quote Link to comment https://forums.phpfreaks.com/topic/283693-somehow-the-insert-from-form-is-failing-wout-error-message/#findComment-1458051 Share on other sites More sharing options...
yshua Posted November 13, 2013 Author Share Posted November 13, 2013 (edited) OK, fellow PHP'ers: Got error log coming out again by resetting the buffer reporting "On" in php.ini and also setting the error_reporting to E-ALL! Brilliant, Mac-gyver, because you made this very worthwhile even without a solution yet. Access.log still is without updates.... Regarding the execution path or symptom, am still researching.... Although the insert fails, the following PHP MySQL queries in followup.php does fine with updates of other lines of data. Does that help? Yshua Edited November 13, 2013 by yshua Quote Link to comment https://forums.phpfreaks.com/topic/283693-somehow-the-insert-from-form-is-failing-wout-error-message/#findComment-1458066 Share on other sites More sharing options...
dalecosp Posted November 13, 2013 Share Posted November 13, 2013 When an insert fails, I always log, mail, or print the SQL query --- it's the best way to debug it (assuming, of course, you speak SQL, and you should, if you intend to program it). Quote Link to comment https://forums.phpfreaks.com/topic/283693-somehow-the-insert-from-form-is-failing-wout-error-message/#findComment-1458109 Share on other sites More sharing options...
yshua Posted November 14, 2013 Author Share Posted November 14, 2013 (edited) Dear Dalecosp: Only WISH to log, mail, or print SQL, but my access.log is still avoiding logging, and am unfamiliar how to do the other (mail or print). Meanwhile, the seqno is auto increment, and could this have something to do with why the insert fails? Zero attempt is made to fill in the seqno, if you notice. Also, a bit of hindsight, does this belong in MySQL installation forum? Yshua Edited November 14, 2013 by yshua Quote Link to comment https://forums.phpfreaks.com/topic/283693-somehow-the-insert-from-form-is-failing-wout-error-message/#findComment-1458269 Share on other sites More sharing options...
Ch0cu3r Posted November 14, 2013 Share Posted November 14, 2013 Only WISH to log, mail, or print SQL, but my access.log is still avoiding logging, access.log as in Apaches access log? It only logs (http) requests not (server) errors. You need to check Apaches error.log for (server) errors. Quote Link to comment https://forums.phpfreaks.com/topic/283693-somehow-the-insert-from-form-is-failing-wout-error-message/#findComment-1458271 Share on other sites More sharing options...
dalecosp Posted November 14, 2013 Share Posted November 14, 2013 (edited) Let's take a look at these lines: if (mysql_query($query) === TRUE) { $_SESSION['seqno'] = mysql_insert_id(); $_SESSION['user'] = $_POST['firstname']; $_SESSION['emailid'] = $_REQUEST['emailid']; }else{ header('Location: form.php?errormsg=Insert Error.'.mysql_error()); #die("Error! Insert failed.Please try again"); } You actually had, at some point, the ability to print planned ... but you're redirecting first. Try something like this for debug purposes *only*: if (mysql_query($query) === TRUE) { $_SESSION['seqno'] = mysql_insert_id(); $_SESSION['user'] = $_POST['firstname']; $_SESSION['emailid'] = $_REQUEST['emailid']; }else{ //header('Location: form.php?errormsg=Insert Error.'.mysql_error()); die("Error! Insert failed. The SQL was $query <br><br> MySQL said: ".mysql_error()); } Edited November 14, 2013 by dalecosp Quote Link to comment https://forums.phpfreaks.com/topic/283693-somehow-the-insert-from-form-is-failing-wout-error-message/#findComment-1458275 Share on other sites More sharing options...
yshua Posted November 15, 2013 Author Share Posted November 15, 2013 Dear Dalecosp: Definitely with all the error message checking now in effect, the insert correctly takes off from the insert.php file without failing! Perhaps warnings/errors in the Javascript as recorded in the Firefox Web Developer Error Console are actually interfering with the insert in Paypal shopping cart protocol, or the unspecified 'seqno' which is specified in Phpmyadmin as "auto_increment" is somehow needing to be specified...? Either way, one or another of these explanations must be the issue! Yshua Quote Link to comment https://forums.phpfreaks.com/topic/283693-somehow-the-insert-from-form-is-failing-wout-error-message/#findComment-1458381 Share on other sites More sharing options...
dalecosp Posted November 15, 2013 Share Posted November 15, 2013 Well, sounds like we're making progress JS errors are not good either, of course; my goal is to eliminate all errors (I'm apparently a tyrannical dictator! ) At any rate, I hope you can get it sorted, and I'll be checking back here periodically... Quote Link to comment https://forums.phpfreaks.com/topic/283693-somehow-the-insert-from-form-is-failing-wout-error-message/#findComment-1458407 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.