Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
raymedia
Forum Commoner
Posts: 27 Joined: Thu Oct 09, 2003 6:36 am
Location: Melbourne, Australia
Post
by raymedia » Thu Mar 23, 2006 6:19 am
i am trying to make this query. but it gaves me error. I realize that this is caused by the field name "FOR" but it's a snycro for a dept. is there anyway around this issue? so i won't get this error. i tried put quotes around the word - 'FOR' but it still not working. even if you direct me to the resources, it'll be great.
Thank you very much in advance.
Code: Select all
$table = "staff";
$field_name = "FOR";
update $table set $field_name='1' where id_staff='$id_staff';
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Thu Mar 23, 2006 6:27 am
use backticks
Code: Select all
$table = "staff";
$field_name = "FOR";
$sql = "UPDATE `$table` SET `$field_name` = '1' WHERE `id_staff` = '$id_staff'";
Benjamin
Site Administrator
Posts: 6935 Joined: Sun May 19, 2002 10:24 pm
Post
by Benjamin » Thu Mar 23, 2006 6:28 am
Code: Select all
$query = "update `staff` set `FOR`='1' where `id_staff`='" . $id_staff . "'";
EDIT- Arg ya beat me.
raymedia
Forum Commoner
Posts: 27 Joined: Thu Oct 09, 2003 6:36 am
Location: Melbourne, Australia
Post
by raymedia » Thu Mar 23, 2006 6:35 am
It works!!! really appriciate it
Cheers