Page 1 of 1

Using a variable in retrieving $_POST

Posted: Wed Jan 21, 2009 9:06 am
by charlie12345
Being comletely new to PHP, I don't understand why/how these two lines are different:

Code: Select all

$item=1;
 
$merchant_product_id[$item] = $_POST["merchant_product_id1"];     #this has a value 
 
$merchant_product_id[$item] = $_POST["$merchant_product_id".$item];    #this has no value
It's obvious I'm missing something somewhere...

Charlie

Re: Using a variable in retrieving $_POST

Posted: Wed Jan 21, 2009 9:23 am
by sergio-pro
the second line contains $ in $merchant_product_id - and it shouldnt

Re: Using a variable in retrieving $_POST

Posted: Wed Jan 21, 2009 9:34 am
by charlie12345
It surely does, doesn't it.

Thanks.
Charlie

Re: Using a variable in retrieving $_POST

Posted: Wed Jan 21, 2009 9:45 am
by tanmay
hi charlie, as being a fresher in php, i would like to tell you that when you are receiving value in $_POST you have to pass a variable.

that you have passed in first statement, that is $_POST["$mkmk_jk"] something like that. and in second statmnt you are passing $_POST["something".$item]. make sure dat its a variable...