PHP/SQL Question

PHP/SQL Question

am 30.06.2006 16:56:15 von schaeffer.kyle

I've been working on a PHP/SQL page for the past few days, and for some
reason I'm having trouble updating/inserting new records in this
application.

I'm getting the following error message while trying to update or
insert a record:

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
'create='Yes',edit='Yes',finalize='Yes',admin='Yes',config=' Yes'

This is the actual SQL statement that I am using:

UPDATE users SET
username='bob',password='password',firstName='Bob',lastName= 'Roberts',department='12100',view='No',create='Yes',edit='Ye s',finalize='Yes',admin='Yes',config='Yes',userm='Yes'
WHERE userID = '1'

I'm not really sure where the synatx error could be. Any help would be
appreciated.

Re: PHP/SQL Question

am 30.06.2006 17:41:11 von jds

On Fri, 30 Jun 2006 07:56:15 -0700, schaeffer.kyle wrote:

> I'm not really sure where the synatx error could be. Any help would be
> appreciated.

Try the SQL statement on the MySQL command line. Do you get an error?

Don't know how to use the MySQL prompt? Try PHPMyAdmin, MySQL
Administrator, or other MySQL admin tool.

The debugging process here should be as follows:

1) Verify that the SQL statement that you posted is, in fact, the SQL
statement that is being sent to the server.

2) Try SQL statement in MySQL directly -- via mysql> prompt, for example.

3) Break SQL statement into several lines and retry it in mysql> prompt.
Having several lines will help narrow down the location of the error.

later...

--
JDS

Re: PHP/SQL Question

am 30.06.2006 20:42:21 von Andy Hassall

On 30 Jun 2006 07:56:15 -0700, schaeffer.kyle@gmail.com wrote:

>I'm getting the following error message while trying to update or
>insert a record:
>
>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
>'create='Yes',edit='Yes',finalize='Yes',admin='Yes',config= 'Yes'

CREATE is a reserved word.

--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool

Re: PHP/SQL Question

am 30.06.2006 23:02:12 von Rik

Andy Hassall wrote:
> On 30 Jun 2006 07:56:15 -0700, schaeffer.kyle@gmail.com wrote:
>
>> I'm getting the following error message while trying to update or
>> insert a record:
>>
>> 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 'create='Yes',edit='Yes',finalize='Yes',admin='Yes',config=' Yes'
>
> CREATE is a reserved word.

Yup, IMO it's always a good idea to use backticks (``) around fieldnames,
even if they aren't reserved words.

Grtz,
--
Rik Wasmus