473,372 Members | 1,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,372 software developers and data experts.

Help with setting variables

hello all,
this is some code that i am using that "loops" through all of the variables
that paypal
ships back to me via ipn.

for ($x=0; $x < count($postvars); $x++)
{ $y=$x+1;
$postkey = $postvars[$x];
$postval = $$postvars[$x];
$postipn.= "&" . $postkey . "=" . urlencode($postval);
$mailipn.= $postkey . " = " . $postval . "\r\n";
}

i then email myself a copy of $mailipn and it contains everything i need.
that part works fine.
however, is it possible to set a variable using the names that were
returned.
for example, paypal sends me back "business", so i would like to set the
value of $business
equal to the value from the paypal post.

normally i would do this:
@$business = $_POST['business'];
but since there are quite a few variables, and the names change (i.e.
shopping carts, etc.)
i would like to set them using the loop posted above (it returns them all).

using the loop above, the "business" line looks like this when echoed:
business = my********@paypal.com

so you see, it would nice to make a $business variable for later use in the
script
that contained my********@paypal.com

thanks.
Jul 16 '05 #1
4 3704
"fartsniff" <fa**@sniff.com> wrote in message news:<vg************@corp.supernews.com>...
hello all,
this is some code that i am using that "loops" through all of the variables
that paypal
ships back to me via ipn.


paypal_post_vars_in_str = "";
foreach($paypal_post_arr as $key=>$value)
{
$value = urlencode(stripslashes($value));
paypal_post_vars_in_str .= "&$key=$value";
}

If you need the value of "business", you may use like
$paypal_post_arr['business']

---
"I have a dream that one day girls will be measured by the size of
their brains than the shape of their flush"
Email: rrjanbiah-at-Y!com
Jul 16 '05 #2
thank you for your help.

"R. Rajesh Jeba Anbiah" <ng**********@rediffmail.com> wrote in message
news:ab**************************@posting.google.c om...
"fartsniff" <fa**@sniff.com> wrote in message

news:<vg************@corp.supernews.com>...
hello all,
this is some code that i am using that "loops" through all of the variables that paypal
ships back to me via ipn.


paypal_post_vars_in_str = "";
foreach($paypal_post_arr as $key=>$value)
{
$value = urlencode(stripslashes($value));
paypal_post_vars_in_str .= "&$key=$value";
}

If you need the value of "business", you may use like
$paypal_post_arr['business']

---
"I have a dream that one day girls will be measured by the size of
their brains than the shape of their flush"
Email: rrjanbiah-at-Y!com

Jul 16 '05 #3
R. Rajesh Jeba Anbiah wrote:
"fartsniff" <fa**@sniff.com> wrote in message news:<vg************@corp.supernews.com>...
hello all,
this is some code that i am using that "loops" through all of the variables
that paypal
ships back to me via ipn.

paypal_post_vars_in_str = "";
foreach($paypal_post_arr as $key=>$value)
{
$value = urlencode(stripslashes($value));
paypal_post_vars_in_str .= "&$key=$value";
}

If you need the value of "business", you may use like
$paypal_post_arr['business']


Going one step further by using PHP's Variable Variables, you could do this:
<?
while (list($key, $val) = each($paypal_post_arr)) {
$$key = $val;
// ^^ - using a variable variable
}
?>

which results in $business being equal to whatever the actual value is.
The only problem is that you have to know what all the variable names
are in order to access them.

Jason
Jul 16 '05 #4

On 4-Jul-2003, "fartsniff" <fa**@sniff.com> wrote:
hello all,
this is some code that i am using that "loops" through all of the
variables
that paypal
ships back to me via ipn.

for ($x=0; $x < count($postvars); $x++)
{ $y=$x+1;
$postkey = $postvars[$x];
$postval = $$postvars[$x];
$postipn.= "&" . $postkey . "=" . urlencode($postval);
$mailipn.= $postkey . " = " . $postval . "\r\n";
}

i then email myself a copy of $mailipn and it contains everything i need.
that part works fine.
however, is it possible to set a variable using the names that were
returned.
for example, paypal sends me back "business", so i would like to set the
value of $business
equal to the value from the paypal post.

normally i would do this:
@$business = $_POST['business'];
but since there are quite a few variables, and the names change (i.e.
shopping carts, etc.)
i would like to set them using the loop posted above (it returns them
all).

using the loop above, the "business" line looks like this when echoed:
business = my********@paypal.com

so you see, it would nice to make a $business variable for later use in
the
script
that contained my********@paypal.com


http://www.php.net/manual/en/function.extract.php

--
Tom Thackrey
www.creative-light.com
Jul 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: mydejamail | last post by:
Coming from an objectpascal background with strict type checking, I am being driven nuts by PHP. Stuff like using variables without declaring them, case sensitivity of variables, getting true,...
5
by: arber | last post by:
Hi, I wrote a C++ program(Using VC 6.0). It's run well under debug environment. After i finished it and made a release version. The different results are outputed. Anybody have this...
8
by: David McDivitt | last post by:
I need to set tabs on java generated pages. Pages have four sections: header, sidebar, body, and footer. The sidebar and body change dynamically. The tab key must go to anchors, fields, and buttons...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
2
by: Hexman | last post by:
Hello All, Well I'm stumped once more. Need some help. Writing a simple select and update program using VB.Net 2005 and an Access DB. I'm using parameters in my update statement and when trying...
2
by: sorobor | last post by:
dear sir .. i am using cakephp freamwork ..By the way i m begener in php and javascript .. My probs r bellow I made a javascript calender ..there is a close button ..when i press close button...
8
by: Eddie | last post by:
I am having difficulty in setting variables in a session, and then accessing those variables throughout the web pages that they click on. After having them set a user name and password,...
4
by: daxco21 | last post by:
I have been working on this simple project for a week, and come to the point where I feel like I need outside help. For the life of me I can't figure out what is wrong with this "sellIceCream(...)"...
1
by: Speebs | last post by:
Hello, I have a little form that people can fill out to generate CD labels from an RTF template. The template basically contains variables that are replaced by the text typed into the form. ...
6
by: xhe | last post by:
I am using ffmpeg to convert video, this is a sample script: $str='/home/transla1/bin/ffmpeg -i /home/transla1/public_html/ cybertube/web/uploads/video/31_AK000005.AVI -s 240x180 -b 100k -ar...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.