papal return page session not s

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

papal return page session not s

Post by jonnyfortis »

i have a return page coming back from paypal. The page is showing either if the order is complete or not.
The trouble i am having is the return.php page seems to be accessing the database to quickly before the database is updated by paypals IPN

i have added a sleep of 5 sec but this doesnt work. if i refresh the page this works.

i have made the if statements versatile so if the incorrect message is displayed it wont show an incorrect message. however now the session isnt showing even though it is started. can anyone tell me if there is a way around this?

Code: Select all

<?php
session_start();
sleep(5);//Added sleep to give database time to update from IPN

$colname_rsReturn = "-1";
if (isset($_SESSION['OrderID'])) {
  $colname_rsReturn = $_SESSION['OrderID'];
}
mysql_select_db($database_beauSS15, $beauSS15);
$query_rsReturn = sprintf("SELECT * FROM beau_orders WHERE OrderID = %s", GetSQLValueString($colname_rsReturn, "int"));
$rsReturn = mysql_query($query_rsReturn, $beauSS15) or die(mysql_error());
$row_rsReturn = mysql_fetch_assoc($rsReturn);
$totalRows_rsReturn = mysql_num_rows($rsReturn);
?>
here are my display outputs

Code: Select all

 <?php if ($row_rsReturn['TransactResult'] == 'Completed'):?>
Your orderID&nbsp;<?php echo $_SESSION['OrderID']; ?>
thanks for shopping please email us with any questions
 <?php endif ; ?>
<?php if ($row_rsReturn['TransactResult'] != 'Completed'):?>
You will recieve an email shortly from PAYPAL regarding your order (<?php echo $_SESSION['OrderID']; ?>).If you do have any questions or enquires please don't hesitate to  contact us.
<?php endif ; ?>
now if the order is complete but doesnt update intime for the database to show "Complete" and <?php if ($row_rsReturn['TransactResult'] != 'Completed'):?> is displayed i am getting an error

Undifined index: OrderID in........

this to me says the session is not starting

thanks
Post Reply