CodeChargenewbie
Posts: 114
|
| Posted: 10/11/2007, 2:33 PM |
|
Is there an equivalent to "for each in request.form" in PHP? foreach() in php doesn't iterate in this manner. I know $_POST is essentially request.form, but how could one accomplish this same task in PHP?
Thank you in adavance.
|
 |
 |
lvalverdeb
Posts: 299
|
| Posted: 10/11/2007, 2:49 PM |
|
try:
foreach($_POST as $fieldname=>$value) {
$settings = "\$" . $fieldname . "='" . $value . "';";
eval($settings);
}
_________________
lvalverdeb
CR, GMT-6
XAMPP/Ubuntu/CCS3.2/4 |
 |
 |
CodeChargenewbie
Posts: 114
|
| Posted: 10/12/2007, 6:09 AM |
|
Quote lvalverdeb:
try:
foreach($_POST as $fieldname=>$value) {
$settings = "\$" . $fieldname . "='" . $value . "';";
eval($settings);
}
Thanks! Most Excellent. I needed this to insert data into a log table and I think this may do the trick.
I do have a follow-up question, if you can be so kind to evaluate:
In the SQL statement for inserting data into the log table, do you have any idea why CCGetSession("UserID") produces no errors, yet $_SESSION["UserID"] gives me an "undefined index: UserID"?
|
 |
 |
DonB
|
| Posted: 10/12/2007, 5:25 PM |
|
Because CCS is smart and checks whether the array element 'isset' before
attempting to reference it.
--
DonB
http://ccswiki.gotodon.net
"CodeChargenewbie" <CodeChargenewbie@forum.codecharge> wrote in message
news:5470f7215dd192@news.codecharge.com...
> Quote lvalverdeb:
> try:
>
> foreach($_POST as $fieldname=>$value) {
> $settings = "\$" . $fieldname . "='" . $value . "';";
> eval($settings);
> }
>
>
>
>
> Thanks! Most Excellent. I needed this to insert data into a log table
and I
> think this may do the trick.
>
> I do have a follow-up question, if you can be so kind to evaluate:
>
> In the SQL statement for inserting data into the log table, do you have
any
> idea why CCGetSession("UserID") produces no errors, yet
$_SESSION["UserID"]
> gives me an "undefined index: UserID"?
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>
|
|
|
 |
lvalverdeb
Posts: 299
|
| Posted: 10/16/2007, 9:58 AM |
|
I guess it is because CCGetSession is supposed to return a value (empty by default) if the session variable is not defined. The CCGetSession function looks like this(note the return statement):
function CCGetSession($parameter_name, $default_value = "")
{
return isset($_SESSION[$parameter_name]) ? $_SESSION[$parameter_name] : $default_value;
}
_________________
lvalverdeb
CR, GMT-6
XAMPP/Ubuntu/CCS3.2/4 |
 |
 |