Paypal [sandbox] and my IPN listener do their stuff and if everything is OK the postback data is inserted into the database. Everything is OK so far data inserted and conf e-mail sent to me.
Paypal then direct the user to me lading page.
The landing page does four things.
Step 1, grabs the second lot postback data paypal sends.
Step 2, query's the database for the record matching the landing pages postback data and compares the query output and the postback data, if they match...
Step 3, send an email with an attached file to the visitors paypal e-mail address which was inserted into the database by the IPN listener.
Step 4, updates the database to reflect that the e-mail has been sent.
The problem lies on the landing page. When the script querys the database. Around 30% of the timearound no data is returned. There are no mysql_error() except that mysql_num_rows() reports no rows affected.
When I check the mysql insert query run from the IPN listener, it has inserted the correct data into the database and the landing page postback data matches this.
Around 30% of the time step 2 above returns empty, the e-mail is not sent [Step 3] and the database is not updated to reflect this [Step 4]
So why can't the landing page query find record in the database?
The query is very simple "SELECT * FROM sales WHERE TT_tx_num = '$g_tx' " [$g_tx is the tx postback var from paypal]
As I've said this does not happen all the time, only around 30% of the time and I have tested it [according to my database 208 times]
I have asked my hosting co if there are any problems with the database servers, they say no.
But if I refresh the landing page everything works fine, email sent database updated ....
Any advice on where to look to sort this out would be very helpful