mysql query problem

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
raymedia
Forum Commoner
Posts: 27
Joined: Thu Oct 09, 2003 6:36 am
Location: Melbourne, Australia

mysql query problem

Post by raymedia »

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';
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

use backticks

Code: Select all

$table = "staff";
$field_name = "FOR";


$sql = "UPDATE `$table` SET `$field_name` = '1' WHERE `id_staff` = '$id_staff'";
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Code: Select all

$query = "update `staff` set `FOR`='1' where `id_staff`='" . $id_staff . "'";
EDIT- Arg ya beat me.
User avatar
raymedia
Forum Commoner
Posts: 27
Joined: Thu Oct 09, 2003 6:36 am
Location: Melbourne, Australia

thakn you Masters

Post by raymedia »

It works!!! really appriciate it :) Cheers
Post Reply