Jump to content

Recommended Posts

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

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.

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 by yshua

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 by mac_gyver

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

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 by yshua

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 by yshua

 

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.

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 by dalecosp

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

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! :D )

 

At any rate, I hope you can get it sorted, and I'll be checking back here periodically...

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.