Click here to Skip to main content
14,236,142 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hello.

This bit of code is to generate a query string from POST items back from PayPal to send to a licensing server but I am getting variable names not variable values.

$CustomerEmail = $_POST['payer_email'];
$CustomerName = $_POST['address_name'];
$OrderRef = $_POST['txn_id'];

fopen('http://192.168.2.2:2112/keygen.php?productid=5&"$CustomerEmail"&"$CustomerName"&quantity="1""&OrderRef"','r');


Results in:

192.168.2.3 - - [24/Jan/2014:10:55:29 -0700] "GET /keygen.php?productid=5&\"$CustomerEmail\"&\"$CustomerName\"&quantity=\"1\"\"&OrderRef\" HTTP/1.0" 200 978 "-" "-"

What I want is:

192.168.2.3 - - [24/Jan/2014:10:55:29 -0700] "GET /keygen.php?productid=5&\buyer@buyer.com&John Doe&quantity="1" 1234567890 HTTP/1.0" 200 978 "-" "-"

The way PHP deals with values of variables vs variable names is throwing this PHP rookie for a loop!

Thanks in advance

:Ron
Posted
Rate this:
Please Sign up or sign in to vote.

Solution 1

Hi Ron,

Try this:

fopen('http://192.168.2.2:2112/keygen.php?productid=5&' . $CustomerEmail . '&' . $CustomerName . '&quantity="1""&OrderRef"','r');


I've done PayPal integration with PHP before myself - not fun!!
Let me know if this helps. :-)
   
v2
Comments
Ron Anders 24-Jan-14 20:43pm
   
Bingo!

Thanks man! That did it.

Onward and Upward!
Mitchell J. 24-Jan-14 20:46pm
   
You're welcome.
Rate this:
Please Sign up or sign in to vote.

Solution 2

PHP doesn't do the variable interpolation into strings delimited with the single-quote (') character.
http://www.php.net/manual/en/language.types.string.php[^]
fopen("http://192.168.2.2:2112/keygen.php?productid=5&$CustomerEmail&$CustomerName&quantity=\"1\"\"&OrderRef\"",'r');

But just using the dot (.) to concatenate, as shown by CraigDJ is probably clearer, since you have double-quotes within the string.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100