Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Paypal IPN - $5 for quick solution!
Old 03-13-2008, 05:13 PM Paypal IPN - $5 for quick solution!
Galaxian's Avatar
Rich Powell

Posts: 842
Name: Rich Powell
Location: United Kingdom
Trades: 0
I will send $5 to anyone who can identify WHY this erroring. Cannot give specific error because Display_errors = Off and don't really want to restart machine to enable it due to sites being on it.

My first question is. Is this code correct? I'm assuming if the payment is valid but not complete it is an echeque so the product they have ordered is set to "waiting".

Ther sneaky error is in this extract of the code somewhere which is causing a blank page. $5 for anyone who can fix it.

PHP Code:
while (!feof($fp)) {
$res fgets ($fp1024);
if (
strcmp ($res"VERIFIED") == 0) {
if (
$payment_status != "completed") or ($receiver_email != $actual_email) or ($payment_amount != $actual_amount)
{
mysql_query("insert into `payment` ('', '$item_name', '$payment_status', '$payment_amount', '$payment_currency', '$txn_id', '$receiver_email', '$payer_email', '$quantity', '$user_id', NOW())");
mysql_query("update codes set `sold_date` = NOW(), `sold_user` = $user_id, `paid` = 'waiting' where `card_type` = '$card_type' and `sold_user` = 0 and `paid` = '' limit $quantity");
}
else
{

mysql_query("insert into payment ('', $item_name$payment_status$payment_amount$payment_currency$txn_id$receiver_email$payer_email$quantity$user_id, NOW())");
$waitingcodes mysql_num_rows(mysql_query("select * from codes where `card_type` = '$card_type' and `sold_user` = $user_id and `paid` = 'waiting'"));
if(
$waitingcodes 0){
mysql_query("update codes set `paid` = 'complete' where `card_type` = '$card_type' `sold_user` = $user_id and paid = 'complete' limit $quantity");

$waitingcodesnew mysql_num_rows(mysql_query("select * from codes where `card_type` = '$card_type' and `sold_user` = $user_id and `paid` = 'waiting'"));

if(
$waitingcodesnew 0){
$newquantity 0;
} else {
$newquantity $waitingcodes $waitingcodesnew;
}
} else {
$newquantity $quantity;
}
if(
$newquantity 0){
mysql_query("update `codes` set `sold_date` = NOW(), `sold_user` = $user_id, paid = 'complete' where `sold_user` = 0 and paid = '' limit $newquantity");
}
}
}
elseif (
strcmp ($res"INVALID") == 0) {
mysql_query("insert into payments ('', $item_name$payment_status$payment_amount$payment_currency$txn_id$receiver_email$payer_email$quantity$user_id, NOW())");
}
}
}
fclose ($fp);
}
print 
"hello"
It never seems to reach hello
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please help get the new
Please login or register to view this content. Registration is FREE
forum started for Webmasters like you!


Last edited by Galaxian; 03-13-2008 at 05:16 PM..
Galaxian is offline
Reply With Quote
View Public Profile Visit Galaxian's homepage!
 
 
Register now for full access!
Old 03-13-2008, 05:23 PM Re: Paypal IPN - $5 for quick solution!
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Your code is a bit messy.. you should start indenting the body of your if statements and loops. At first glance your insert queries don't seem to be using correct syntax. I'm not sure if the way you are doing it works or not but generally an insert looks more like this:
Code:
INSERT INTO tbl_name (`column1` , `column2`) VALUES( 'value1' , 'value2');
What you have is this:

Code:
INSERT INTO tbl_name ('value1' , 'value2');
I may be wrong but that was the first thing that caught my eye. Without an error message its kind of hard to pick out where the problem is. I suggest turning error messages on and using @ to suppress warnings and errors
PHP Code:
$result mysql_query('BAD QUERY');
mysql_fetch_array($resultMYSQL_ASSOC//will generate an error message without a valid $result
@mysql_fetch_array($resultMYSQL_ASSOC//will not 
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by NullPointer; 03-13-2008 at 05:28 PM..
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 03-13-2008, 05:25 PM Re: Paypal IPN - $5 for quick solution!
VirtuosiMedia's Avatar
Web Design Made Simple

Posts: 1,228
Trades: 0
I think you have too many closing braces. I indented your code and the last two braces didn't seem like they belonged.

PHP Code:
}
fclose ($fp);


Last edited by VirtuosiMedia; 03-13-2008 at 05:26 PM..
VirtuosiMedia is offline
Reply With Quote
View Public Profile Visit VirtuosiMedia's homepage!
 
Old 03-13-2008, 05:35 PM Re: Paypal IPN - $5 for quick solution!
Galaxian's Avatar
Rich Powell

Posts: 842
Name: Rich Powell
Location: United Kingdom
Trades: 0
Thanks to both of you. However the error is still not fixed. I will now include more of the code. I think maybe the 2 braces you pointed out belong in this.

PHP Code:
if (!$fp) {
echo 
"There was a problem connecting to the IPN server, check your port status.";
} else {
fputs ($fp$header $req);
while (!
feof($fp)) {
$res fgets ($fp1024);
if (
strcmp ($res"VERIFIED") == 0) {
if (
$payment_status != "completed") or ($receiver_email != $actual_email) or ($payment_amount != $actual_amount)
{
mysql_query("insert into `payment` values ('', '$item_name', '$payment_status', '$payment_amount', '$payment_currency', '$txn_id', '$receiver_email', '$payer_email', '$quantity', '$user_id', NOW())");
mysql_query("update codes set `sold_date` = NOW(), `sold_user` = $user_id, `paid` = 'waiting' where `card_type` = '$card_type' and `sold_user` = 0 and `paid` = '' limit $quantity");
}
else
{

mysql_query("insert into payment values ('', $item_name$payment_status$payment_amount$payment_currency$txn_id$receiver_email$payer_email$quantity$user_id, NOW())");
$waitingcodes mysql_num_rows(mysql_query("select * from codes where `card_type` = '$card_type' and `sold_user` = $user_id and `paid` = 'waiting'"));
if(
$waitingcodes 0){
mysql_query("update codes set `paid` = 'complete' where `card_type` = '$card_type' `sold_user` = $user_id and paid = 'complete' limit $quantity");

$waitingcodesnew mysql_num_rows(mysql_query("select * from codes where `card_type` = '$card_type' and `sold_user` = $user_id and `paid` = 'waiting'"));

if(
$waitingcodesnew 0){
$newquantity 0;
} else {
$newquantity $waitingcodes $waitingcodesnew;
}
} else {
$newquantity $quantity;
}
if(
$newquantity 0){
mysql_query("update `codes` set `sold_date` = NOW(), `sold_user` = $user_id, paid = 'complete' where `sold_user` = 0 and paid = '' limit $newquantity");
}
}
}
elseif (
strcmp ($res"INVALID") == 0) {
mysql_query("insert into payment values ('', $item_name$payment_status$payment_amount$payment_currency$txn_id$receiver_email$payer_email$quantity$user_id, NOW())");
}
}
}
fclose ($fp);
}
print 
"hello"
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please help get the new
Please login or register to view this content. Registration is FREE
forum started for Webmasters like you!


Last edited by Galaxian; 03-13-2008 at 05:36 PM..
Galaxian is offline
Reply With Quote
View Public Profile Visit Galaxian's homepage!
 
Old 03-13-2008, 05:38 PM Re: Paypal IPN - $5 for quick solution!
VirtuosiMedia's Avatar
Web Design Made Simple

Posts: 1,228
Trades: 0
Check your while loop condition. You could be going into an infinite loop. That would keep it from displaying the hello at the bottom.

I didn't know feof is a function.

Last edited by VirtuosiMedia; 03-13-2008 at 05:47 PM..
VirtuosiMedia is offline
Reply With Quote
View Public Profile Visit VirtuosiMedia's homepage!
 
Old 03-13-2008, 05:41 PM Re: Paypal IPN - $5 for quick solution!
Galaxian's Avatar
Rich Powell

Posts: 842
Name: Rich Powell
Location: United Kingdom
Trades: 0
Page is status 'Done' in the browser with no apparent continuing communication with the server.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please help get the new
Please login or register to view this content. Registration is FREE
forum started for Webmasters like you!

Galaxian is offline
Reply With Quote
View Public Profile Visit Galaxian's homepage!
 
Old 03-13-2008, 05:49 PM Re: Paypal IPN - $5 for quick solution!
VirtuosiMedia's Avatar
Web Design Made Simple

Posts: 1,228
Trades: 0
Try changing this:

PHP Code:
if ($payment_status != "completed") or ($receiver_email != $actual_email) or ($payment_amount != $actual_amount){ 
to this:

PHP Code:
if (($payment_status != "completed") or ($receiver_email != $actual_email) or ($payment_amount != $actual_amount)){ 
Also, unless there's more code above, you still have an extra brace at the end.

Last edited by VirtuosiMedia; 03-13-2008 at 05:53 PM..
VirtuosiMedia is offline
Reply With Quote
View Public Profile Visit VirtuosiMedia's homepage!
 
Old 03-13-2008, 05:52 PM Re: Paypal IPN - $5 for quick solution!
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
Try running those queries through phpmyadmin if you can to see if they are valid. Seriously though.. testing code without error messages is not the best way to go about things.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 03-13-2008, 05:55 PM Re: Paypal IPN - $5 for quick solution!
VirtuosiMedia's Avatar
Web Design Made Simple

Posts: 1,228
Trades: 0
Quote:
Originally Posted by NullPointer View Post
Try running those queries through phpmyadmin if you can to see if they are valid. Seriously though.. testing code without error messages is not the best way to go about things.
I agree on that...
VirtuosiMedia is offline
Reply With Quote
View Public Profile Visit VirtuosiMedia's homepage!
 
Old 03-13-2008, 06:08 PM Re: Paypal IPN - $5 for quick solution!
Galaxian's Avatar
Rich Powell

Posts: 842
Name: Rich Powell
Location: United Kingdom
Trades: 0
Quote:
Originally Posted by NullPointer View Post
Try running those queries through phpmyadmin if you can to see if they are valid. Seriously though.. testing code without error messages is not the best way to go about things.
These queries aren't being executed yet because of the error. However even commenting out the queries produces no results.

I tried the code change NullPointer suggested but didn't have any effect.

As for the testing of it I've explained already.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please help get the new
Please login or register to view this content. Registration is FREE
forum started for Webmasters like you!

Galaxian is offline
Reply With Quote
View Public Profile Visit Galaxian's homepage!
 
Old 03-13-2008, 06:11 PM Re: Paypal IPN - $5 for quick solution!
VirtuosiMedia's Avatar
Web Design Made Simple

Posts: 1,228
Trades: 0
This probably won't get it to show if commenting out the queries doesn't do anything, but on some of your queries, you're using a ` instead of a '. That will send an error. Also have you tried echoing anything above the first conditional?
VirtuosiMedia is offline
Reply With Quote
View Public Profile Visit VirtuosiMedia's homepage!
 
Old 03-13-2008, 08:07 PM Re: Paypal IPN - $5 for quick solution!
Galaxian's Avatar
Rich Powell

Posts: 842
Name: Rich Powell
Location: United Kingdom
Trades: 0
Thanks for all your helps.

Fortunately I was able to fix the problem after restarting the server at a low peak time and change the error settings. I tell you - debugging is so much easier. Fixed it within a seconds. Apologies for wasting time.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Please help get the new
Please login or register to view this content. Registration is FREE
forum started for Webmasters like you!

Galaxian is offline
Reply With Quote
View Public Profile Visit Galaxian's homepage!
 
Reply     « Reply to Paypal IPN - $5 for quick solution!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.36352 seconds with 12 queries