Post Issue

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Johnlbuk
Forum Newbie
Posts: 19
Joined: Mon Sep 10, 2007 3:01 pm

Post Issue

Post 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
User avatar
markusn00b
Forum Contributor
Posts: 298
Joined: Sat Oct 20, 2007 2:16 pm
Location: York, England

Re: Post Issue

Post 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}"];
User avatar
aceconcepts
DevNet Resident
Posts: 1424
Joined: Mon Feb 06, 2006 11:26 am
Location: London

Re: Post Issue

Post by aceconcepts »

Remove the $ symbol from the post variable

Code: Select all

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

Code: Select all

 
$post=$_POST['setting'];
 
Johnlbuk
Forum Newbie
Posts: 19
Joined: Mon Sep 10, 2007 3:01 pm

Re: Post Issue

Post by Johnlbuk »

Thanks! That did the trick :)
Post Reply