Order API - PHP/mySQL

General ShopSite user discussion

Order API - PHP/mySQL

Postby tgavin » Sat Sep 01, 2007 1:37 pm

This works. I receive an email with the first name
Code: Select all
$stdin = fopen("php://stdin","r");
fscanf($stdin,"%{$SERVER['CONTENT_LENGTH']}s",$query_string);
parse_str($query_string,$params);
$fname = $params['First'];

// send email
mail('me@address.com','subject',$fname);


This doesn't work
Code: Select all
$stdin = fopen("php://stdin","r");
fscanf($stdin,"%{$SERVER['CONTENT_LENGTH']}s",$query_string);
parse_str($query_string,$params);
$fname = $params['First'];

// db connection stuff here
$sql = mysql_query("INSERT INTO table (fname) VALUES ('$fname')");


So, if PHP is working enough to send me an email with the SS data, why in the world can't it INSERT to a mysql db? Actually, mail() is the ONLY thing that I've been able to get working. I can't even write to a text file!

Frustrating doesn't even begin to describe it. Is it because I'm using PayPal? Even though I'm testing with an AMEX card and not going to PayPal's site?
tgavin
 
Posts: 13
Joined: Mon Jul 09, 2007 9:05 am

Postby Jim » Sat Sep 01, 2007 4:36 pm

I don't know anything about php but have you checked this post
http://support.shopsite.com/forums/view ... ht=php+api
that documents how one person was able to use it?

Also what version of ShopSite are you using? If you use the test program customdump.cgi does the field you need get displayed?
Jim
Site Admin
 
Posts: 4953
Joined: Fri Aug 04, 2006 1:42 pm
Location: Utah

Postby tgavin » Sat Sep 01, 2007 5:04 pm

Jim wrote:I don't know anything about php but have you checked this post
http://support.shopsite.com/forums/view ... ht=php+api
that documents how one person was able to use it?
That's the post that got me started :) However, he's not doing what I'm trying to do.

Jim wrote:Also what version of ShopSite are you using? If you use the test program customdump.cgi does the field you need get displayed?
I was hoping the latest version might have a change, so I upgraded to 8.3.1 earlier today. No change.

I first used customdump.cgi to get the fields I wanted, then set them up in my PHP script. So, everything I want is in my array, I just can't get it into mysql.

I've been messing with this for hours and hours over the course of two days. It shouldn't be this difficult, especially if I *know* PHP is working correctly!
tgavin
 
Posts: 13
Joined: Mon Jul 09, 2007 9:05 am

Postby loren_d_c » Sat Sep 01, 2007 8:39 pm

I was hoping the latest version might have a change, so I upgraded to 8.3.1 earlier today. No change.


If the CGI name/value pair is shown to be there via either customdump.cgi (or custom-dump.pl may be available as well in some older versions or stores upgraded from older versions), and you have shown that you can access this value with the PHP scripting language to do other stuff with the value, i.e. email it, then I really don't think the problem is a ShopSite-specific problem and upgrading your ShopSite version is not going to have any effect.

Can you make other inserts into this MySQL database from your custom Order API script, i.e. a similar insert but using hard-coded values instead of variables? If not, then perhaps there is a connection or permissions problem with your MySQL db.

-Loren
loren_d_c
 
Posts: 2572
Joined: Fri Aug 04, 2006 12:02 pm
Location: Anywhere

Postby tgavin » Sun Sep 02, 2007 11:22 am

Thanks Loren.

I said "My TV won't work" and you basically asked me "Is it plugged in"?

Got it working :)
tgavin
 
Posts: 13
Joined: Mon Jul 09, 2007 9:05 am


Return to User Forum

Who is online

Users browsing this forum: No registered users and 127 guests