Jump to content

php not reading my variable.


ballhogjoni

Recommended Posts

I am sending this information to another server. For some reason the other server cannot read my $ccnumber variable. Any help would be appreciated.

[code]//code start
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$result = mysql_query("SELECT first, last, email, address, city, state, zipcode, phone FROM articlecash ORDER BY id DESC");

$result2 = mysql_query("SELECT ccnumber, expyear, expmonth FROM articlecashccinfo ORDER BY id DESC");

$result1 = mysql_fetch_array($result);
$result3 = mysql_fetch_array($result2);

mysql_close();

$phone = $result1['phone'];
$first = $result1['first'];
$last = $result1['last'];
$email = $result1['email'];
$address = $result1['address'];
$city = $result1['city'];
$state = $result1['state'];
$zipcode = $result1['zipcode'];
$ccnumber = $result3['ccnumber'];
$expyear = $result3['expyear'];
$expmonth = $result3['expmonth'];
$username = 'XXXXXX';
$password = 'XXXXXX';
$command = "user.configure";
$user_id = "NEW";
$url = "https://www.XXXXXX.com/auto/api.php?partner_login=$username&partner_password=$password&test=TRUE&command=$command&user_id=$user_id&service=\"code=DS,frequency=M,action=add,renewal_billed_to=U,trial=14\"&output=php&phone=$phone&first_name=$first&last_name=$last&bill_address1=$address&bill_address2=&bill_city=$city&bill_state=$state&bill_postal=$zipcode&bill_country=US&username=foousername&password=foopassword&cc_num=$ccnumber&cc_exp=$expyear-$expmonth&email=$email";

$ch = curl_init();
curl_setopt( $ch , CURLOPT_URL , $url); //the url
curl_setopt($ch, CURLOPT_FAILONERROR, 1); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects 
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable 
curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s 
curl_setopt($ch, CURLOPT_POST, 1); // set POST method
$ret = curl_exec($ch);
curl_close($ch);

echo $ret;

?>
// code end[/code]
Link to comment
Share on other sites

You've set:
curl_setopt($ch, CURLOPT_POST, 1);

But you didnt send any post information using CURLOPT_POSTFIELDS, you've only sent GET data (in the URL itself).
I think you meant doing:

[code]<?php

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$result = mysql_query("SELECT first, last, email, address, city, state, zipcode, phone FROM articlecash ORDER BY id DESC");

$result2 = mysql_query("SELECT ccnumber, expyear, expmonth FROM articlecashccinfo ORDER BY id DESC");

$result1 = mysql_fetch_array($result);
$result3 = mysql_fetch_array($result2);

mysql_close();

$phone = $result1['phone'];
$first = $result1['first'];
$last = $result1['last'];
$email = $result1['email'];
$address = $result1['address'];
$city = $result1['city'];
$state = $result1['state'];
$zipcode = $result1['zipcode'];
$ccnumber = $result3['ccnumber'];
$expyear = $result3['expyear'];
$expmonth = $result3['expmonth'];
$username = 'XXXXXX';
$password = 'XXXXXX';
$command = "user.configure";
$user_id = "NEW";
$url = "https://www.XXXXXX.com/auto/api.php";

$ch = curl_init();
curl_setopt( $ch , CURLOPT_URL , $url); //the url
curl_setopt($ch, CURLOPT_FAILONERROR, 1); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects 
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable 
curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s 
curl_setopt($ch, CURLOPT_POST, 1); // set POST method
curl_setopt($ch, CURL_POSTFIELDS, "partner_login=$username&partner_password=$password&test=TRUE&command=$command&user_id=$user_id&service=\"code=DS,frequency=M,action=add,renewal_billed_to=U,trial=14\"&output=php&phone=$phone&first_name=$first&last_name=$last&bill_address1=$address&bill_address2=&bill_city=$city&bill_state=$state&bill_postal=$zipcode&bill_country=US&username=foousername&password=foopassword&cc_num=$ccnumber&cc_exp=$expyear-$expmonth&email=$email");
$ret = curl_exec($ch);
curl_close($ch);

echo $ret;

?>[/code]

I must mention that you should use urlencode() on the data you are sending. You can have a few problems if you dont use it.

Orio.
Link to comment
Share on other sites

I thought the same thing. the other server says I am forgetting "code=2&text=Parameter+Missing%3A+partner_login%2Cpartner_password%2Ccommand&version=3.0"

The code I have works if I manually put a credit card number in the place of $ccnumber. Example: &cc_num=411111111111111&

So my question is How come my variable is not being read in the url string.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.