Page 1 of 1

Post Issue

Posted: Sat Apr 26, 2008 4:16 am
by Johnlbuk
Hi,
I am trying to run a update query. The problem is that the name of the input field changes as the field are created from a table in the database.

I am trying therefore to insert the value from the field in the database using the following code.

Code: Select all

$rowid = $data["id"];
$setting = $data["setting"];
 
$post = $_POST['$setting']; ($setting inserted into the post variable)
 
$query = "UPDATE tblpaymentgateways SET value='$post' WHERE id='$rowid'";
$result=mysql_query($query);
However, it just update blank. I think the problem lies with the $post but not sure how to work around this. Any help would be great :)
Regards,
John

Re: Post Issue

Posted: Sat Apr 26, 2008 5:33 am
by markusn00b
Johnlbuk wrote:Hi,
I am trying to run a update query. The problem is that the name of the input field changes as the field are created from a table in the database.

I am trying therefore to insert the value from the field in the database using the following code.

Code: Select all

$rowid = $data["id"];
$setting = $data["setting"];
 
$post = $_POST['$setting']; ($setting inserted into the post variable)
 
$query = "UPDATE tblpaymentgateways SET value='$post' WHERE id='$rowid'";
$result=mysql_query($query);
However, it just update blank. I think the problem lies with the $post but not sure how to work around this. Any help would be great :)
Regards,
John
$variables will not be parsed inside single quotes!
Try changing $_POST['$setting'] to $_POST["{$setting}"];

Re: Post Issue

Posted: Sat Apr 26, 2008 7:14 am
by aceconcepts
Remove the $ symbol from the post variable

Code: Select all

 
$post=$_POST['$setting'];
 
should be:

Code: Select all

 
$post=$_POST['setting'];
 

Re: Post Issue

Posted: Sat Apr 26, 2008 9:41 am
by Johnlbuk
Thanks! That did the trick :)