homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

Very simple MYSQL query, major problems

10+ Year Member

Msg#: 4659129 posted 11:38 am on Apr 1, 2014 (gmt 0)

Hi guys, your valued advice is needed.

Short version ;-)

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

Thank you for your time.



Msg#: 4659129 posted 9:31 am on Apr 2, 2014 (gmt 0)

As you can see, you cannot rely on the IPN being called before a client is returned to your landing page. If the IPN fails due to your server/network going unavailable it will keep on trying.

You should send a confirmation email at the end of the IPN call.

Your landing page should do nothing then thank the customer for his order and say a confirmation will be sent shortly.


10+ Year Member

Msg#: 4659129 posted 6:45 pm on Apr 2, 2014 (gmt 0)

Thank you for your reply. I was coming to the same conclusion.

I was under the misguided impression that IPN listener would do it stuff before the client was sent back to the site.

I will do as you suggest and send the email at the end of the IPN call

Thanks once again.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved