English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hi i have this weird php code and im gettin an error anybody knows how to fix it?
$var = "$". $row2['id'];
$$var= $_POST['$row['id']'];
error is on the second line

2006-07-12 08:05:20 · 6 answers · asked by aryaxt 3 in Computers & Internet Programming & Design

Parse error: parse error, unexpected T_STRING, expecting ']'

2006-07-12 08:11:29 · update #1

6 answers

what is the error you are getting? Also, do you have any sample data for $row2['id']?

the problem is the single quotes in $_POST['$row['id']']
it should be $_POST[$row['id']].

the single quotes were breaking and the parser was seeing:
$_POST['$row[' id ']']

you may still run into other issues, I'm not sure what having the $ alone in the quotes for that first line will do.

2006-07-12 08:09:03 · answer #1 · answered by John J 6 · 0 0

$var = "$". $row2['id'];
$$var= $_POST['$row['id']'];

change to:

$varA = "$". $row2['id'];
$varB = $_POST[$row['id']];

That should pass validation, before I expect it was having trouble working out your quotes.

Also please note that in PHP you can have varible variables so if memory is correct something like:

$a = 'b';
$b = 'c';
$c = $$a;


... is valid.

That said I've not used PHP in quite a long time now and haven't checked that code; I'll leave that up to you if you can be bothered :-)

2006-07-12 15:20:19 · answer #2 · answered by Tim C 1 · 0 0

you only need one $ sign in front of "var"..

the $ tells PHP it is a variable.. looks like it tries to get a POST variable by a certain name, stored in an array called $row... it is difficult to understand what this code is exactly doing.. you might get logic errors because of it.

2006-07-12 15:10:34 · answer #3 · answered by xx342334234234 2 · 0 0

Use this
$var = "$". $row2['id'];
$$var= $_POST[$row['id']];

Got it (onlykeshu@yahoo.co.in)

2006-07-17 05:47:31 · answer #4 · answered by keshu 2 · 0 0

Try this

$var = "$". $row2['id'];
$var1= $_POST['$var'];

2006-07-12 15:18:44 · answer #5 · answered by Anonymous · 0 0

maybe it's supposed to be $var instead of $$var

2006-07-12 15:09:16 · answer #6 · answered by Deep Thought 5 · 0 0

fedest.com, questions and answers