Strange Behavior using MySQL
Here is my query:
$query = "UPDATE money SET value = '5' WHERE key = 'one'";
When I run the page, the query dies saying:
You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'key = 'one'' at
line 1
The same thing happens when I use INSERT or other functions. I have used
them before, but now I seem to be having troubles. Can anyone find any
mistakes? I'm running XAMPP 1.6.0a on a Windows machine.
Re: Strange Behavior using MySQL
Reserved words:
http://dev.mysql.com/doc/refman/5.0/en/reserved-words.html
--
Chris
http://www.veign.com / http://www.veign.com/blog
--
"Matt White" <mgw854 [at] msn.com> wrote in message
news:hWO_h.48$LJ3.27 [at] trnddc02...
> Here is my query:
>
> $query = "UPDATE money SET value = '5' WHERE key = 'one'";
>
> When I run the page, the query dies saying:
>
> You have an error in your SQL syntax; check the manual that corresponds to
> your MySQL server version for the right syntax to use near 'key = 'one''
> at line 1
>
> The same thing happens when I use INSERT or other functions. I have used
> them before, but now I seem to be having troubles. Can anyone find any
> mistakes? I'm running XAMPP 1.6.0a on a Windows machine.
Re: Strange Behavior using MySQL
Matt White wrote:
> Here is my query:
>
> $query = "UPDATE money SET value = '5' WHERE key = 'one'";
As you been using reserved words as column name this is how the query should
look like:
$query = "UPDATE money SET value = '5' WHERE `key` = 'one'";
Next time you create a table, do take a look at the page Veign posted and do
not use those column/table names that are listed there.
--
//Aho
Re: Strange Behavior using MySQL
Thanks a lot! It now works. I didn't know that there were reserved words
in MySQL.
"J.O. Aho" <user [at] example.net> wrote in message
news:5a2j3qF2mpuglU1 [at] mid.individual.net...
> Matt White wrote:
>> Here is my query:
>>
>> $query = "UPDATE money SET value = '5' WHERE key = 'one'";
>
> As you been using reserved words as column name this is how the query
> should
> look like:
> $query = "UPDATE money SET value = '5' WHERE `key` = 'one'";
>
> Next time you create a table, do take a look at the page Veign posted and
> do
> not use those column/table names that are listed there.
> --
>
> //Aho
Re: Strange Behavior using MySQL
Safest thing is to assume there are always reserved words anything
development, which there are...
--
Chris
http://www.veign.com / http://www.veign.com/blog
--
"Matt White" <mgw854 [at] msn.com> wrote in message
news:pq1%h.477$wy2.253 [at] trnddc03...
> Thanks a lot! It now works. I didn't know that there were reserved words
> in MySQL.
>
> "J.O. Aho" <user [at] example.net> wrote in message
> news:5a2j3qF2mpuglU1 [at] mid.individual.net...
>> Matt White wrote:
>>> Here is my query:
>>>
>>> $query = "UPDATE money SET value = '5' WHERE key = 'one'";
>>
>> As you been using reserved words as column name this is how the query
>> should
>> look like:
>> $query = "UPDATE money SET value = '5' WHERE `key` = 'one'";
>>
>> Next time you create a table, do take a look at the page Veign posted and
>> do
>> not use those column/table names that are listed there.
>> --
>>
>> //Aho
>