Welcome to Dream.In.Code
Become an Expert!

Join 149,788 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,772 people online right now. Registration is fast and FREE... Join Now!




weird syntax error

 
Reply to this topicStart new topic

weird syntax error

ktsirig
3 Feb, 2007 - 09:15 AM
Post #1

D.I.C Head
**

Joined: 14 Sep, 2005
Posts: 71


My Contributions
Hello all,
I am trying to create a table using the following syntax:

mysql_query ("CREATE TABLE IF NOT EXISTS RETURN (
RETURN_ID INT(12) NOT NULL AUTO_INCREMENT,
RETURN_RENTAL_ID INT(12) NOT NULL,
RETURN_COPY_ID INT(12) NOT NULL,
RETURN_MOVIE_ID INT(12) NOT NULL,
RETURN_DATE DATE NOT NULL,
PRIMARY KEY (RETURN_ID),
CONSTRAINT RETURN_IBFK_1 FOREIGN KEY(RETURN_RENTAL_ID) REFERENCES RENTAL(RENTAL_ID),
CONSTRAINT RETURN_IBFK_2 FOREIGN KEY(RETURN_COPY_ID) REFERENCES COPY(COPY_ID),
CONSTRAINT RETURN_IBFK_3 FOREIGN KEY(RETURN_MOVIE_ID) REFERENCES MOVIE(MOVIE_ID))"
) || die(mysql_error());

I get the following error:
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 'RETURN ( RETURN_ID INT(12) NOT NULL AUTO_INCREMENT, RETURN_RENTAL_ID I' at line 1


I am trying for 3 hours now to find what the problem is... I have checked everything, all about the foreign keys I use etc, but nothing seems to work... I can't see what my syntax error is...
Any help is greatly appreciated...

User is offlineProfile CardPM
+Quote Post

wzeller
RE: Weird Syntax Error
3 Feb, 2007 - 10:32 PM
Post #2

New D.I.C Head
Group Icon

Joined: 9 Apr, 2006
Posts: 39


Dream Kudos: 25
My Contributions
I may be missing something (I'll freely admit that a bunch of that code looks like it's over my head), but it appears that you aren't specifying a table name.

Could it be that easy?

Wayne

User is offlineProfile CardPM
+Quote Post

Trogdor
RE: Weird Syntax Error
7 Feb, 2007 - 02:45 AM
Post #3

D.I.C Addict
Group Icon

Joined: 6 Oct, 2006
Posts: 549



Thanked: 4 times
Dream Kudos: 125
My Contributions
And is the IF NOT EXISTS RETURN something mysql specific, or spurious ?

User is offlineProfile CardPM
+Quote Post

Abbygail
RE: Weird Syntax Error
7 Feb, 2007 - 06:16 AM
Post #4

D.I.C Head
**

Joined: 13 Jul, 2006
Posts: 61


My Contributions
I think RETURN is a mysql key word because this seems to work but if i change the RETURNED to RETURN it fails....
I'm running mysql 5.something on ubuntu 6.10... so there may be issues between different versions and systems.
You will have to validate it though.
Hope it helps.

CREATE TABLE IF NOT EXISTS RETURNED ( RETURN_ID INT(12) NOT NULL AUTO_INCREMENT, RETURN_RENTAL_ID INT(12) NOT NULL, RETURN_COPY_ID INT(12) NOT NULL, RETURN_MOVIE_ID INT(12) NOT NULL, RETURN_DATE DATE NOT NULL, PRIMARY KEY (RETURN_ID), CONSTRAINT RETURN_IBFK_1 FOREIGN KEY(RETURN_RENTAL_ID) REFERENCES RENTAL(RENTAL_ID), CONSTRAINT RETURN_IBFK_2 FOREIGN KEY(RETURN_COPY_ID) REFERENCES COPY(COPY_ID), CONSTRAINT RETURN_IBFK_3 FOREIGN KEY(RETURN_MOVIE_ID) REFERENCES MOVIE(MOVIE_ID));
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 07:16AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month