Click here to Skip to main content
15,881,424 members
Please Sign up or sign in to vote.
5.00/5 (1 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

Hi Ron,

Try this:

PHP
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. :-)
 
Share this answer
 
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.
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[^]
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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900