Go Back   Computer Forums > Web Design | Website Development > Web Programming
Click Here to Login
Join Computer forums Today

Thread Tools Search this Thread Display Modes
Old 06-28-2006, 11:32 PM   #1
Baseband Member
Join Date: Jan 2006
Posts: 23
Default PayPal IPN MADNESS!!!

So. I've been getting my webstore all PayPal savvy and everything and I'm only finding one problem with my Instant Payment Notification handler and it doesn't even have to do with what PayPal posts to the page (i think...)

Here's the bit I'm having trouble with (if you need the rest for reference let me know)
PHP Code:
if ($txn_type == "cart"){
$strQuery "insert into customers(paymentstatus,email,first_name,last_name,street,city,state,zip,country,mc_gross,mc_fee,memo,paymenttype,paymentdate,txnid,num_items,pendingreason,reasoncode,tax,datecreation) values ('".$payment_status."','".$payer_email."','".$first_name."','".$last_name."','".$address_street."','".$address_city."','".$address_state."','".$address_zip."','".$address_country."','".$mc_gross."','".$mc_fee."','".$memo."','".$payment_type."','".$payment_date."','".$txn_id."','".$num_cart_items."','".$pending_reason."','".$reason_code."','".$tax."','".$fecha."')";

$result mysql_query($strQuery) or die("Cart - customers, Query failed:<br>" mysql_error() . "<br>" mysql_errno());
     for (
$i 1$i <= $num_cart_items$i++) {
$itemname "item_name".$i;
$itemnumber "item_number".$i;
$quantity "quantity".$i;

$strQuery2 "insert into purchases(txnid,item_number,item_name,quantity,invoice,custom) values ('".$txn_id."','".$_POST[$itemnumber]."','".$_POST[$itemname]."','".$_POST[$quantity]."','".$invoice."','".$custom."')";
$result mysql_query($strQuery2) or die("Cart - purchases, Query failed:<br>" mysql_error() . "<br>" mysql_errno());
$products "SELECT * FROM `products` WHERE `prod_id` = '".$_POST[$itemnumber]."'  ";
$strQuery3 mysql_query($products);
$change_stock mysql_fetch_assoc($strQuery3)) {
$stock      stripslashes$change_stock['stock'] );
$new_stock $stock $_POST[$quantity];
$strQuery4 "UPDATE `products` SET `stock` = '".$_POST[$newstock]."' WHERE `prod_id` = '".$_POST[$itemnumber]."'  ";
Everything's fine when I'm trying to insert the new data. It's trying to update my stock that is the problem. When the form mails the variable strQuery4 to me it says
UPDATE `products` SET `stock` = '' WHERE `prod_id` = '02020202'

At first I'm like "Yay!" because it got the prod_id of the item to show up but I can't get the newstock number I want it to use to replace the old stock number.

Being that I'm very very very new to php I wouldn't be surprised if it is some syntax error but at the same time the handler says everything is fine and dandy. Any clues?

Thanks and sorry for the lengthy post

blondegeek is offline   Reply With Quote
Old 06-29-2006, 06:20 AM   #2
Site Team
root's Avatar
Join Date: Mar 2004
Posts: 8,098
Default Re: PayPal IPN MADNESS!!!

the problem appear to be that the variable $_POST['newstock'] doesn't have a value,

I think that yur query for this is meant to be...

$strQuery4 = "UPDATE `products` SET `stock` = '".$new_stock."' WHERE `prod_id` = '".$_POST[$itemnumber]."'  ";

I didn’t fight my way to the top of the food chain to be a vegetarian…
Im sick of people saying 'dont waste paper'. If trees wanted to live, they'd all carry guns.
"The inherent vice of capitalism is the unequal sharing of blessings; The inherent vice of socialism is the equal sharing of miseries."
root is offline   Reply With Quote
Old 06-29-2006, 10:23 AM   #3
Baseband Member
Join Date: Jan 2006
Posts: 23
Default Re: PayPal IPN MADNESS!!!

Ah, the one thing I didn't try. It always comes to that. Thank you! (you know, root, you're usually the first and only person to answer my posts and with the correct solution too)

Turns out there were two problems: 1) the problem that was solved above 2) prod_id is not a column in my database but pro_id is. It's always the simple things

Thanks again!
blondegeek is offline   Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
Pingbacks are On
Refbacks are Off

All times are GMT -5. The time now is 09:29 PM.

Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0