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
https://forums.phpfreaks.com/topic/34159-php-not-reading-my-variable/
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.
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.