Mar

24

If you have read the CakePHP tutorial Cook up Web sites fast with CakePHP MySQL Syntax Problem, Part 2 from IBM, you may have encountered a problem at Section 3. Scaffolding -> Setting up the product tables -> Creating tables to hold product information. When you run the following MySQL query:

CREATE TABLE 'products' (
'id' INT( 10 ) NOT NULL AUTO_INCREMENT ,
'title' VARCHAR( 255 ) NOT NULL ,
'dealer_id' INT( 10 ) NOT NULL ,
'description' blob NOT NULL ,
PRIMARY KEY ('id')
) TYPE = MYISAM ;
CREATE TABLE 'dealers' (
'id' INT( 10 ) NOT NULL AUTO_INCREMENT ,
'title' VARCHAR( 255 ) NOT NULL ,
PRIMARY KEY ('id')
) TYPE = MYISAM ;

You will get an error message like the one below:

#1064 - 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 ''products' (
'id' INT( 10 ) NOT NULL AUTO_INCREMENT ,
'title' VARCHAR( 255 ) N' at line 1


The syntax error is that all the ‘ in the query should be `, so the following queries will work fine:

CREATE TABLE `products` (
`id` INT( 10 ) NOT NULL AUTO_INCREMENT ,
`title` VARCHAR( 255 ) NOT NULL ,
`dealer_id` INT( 10 ) NOT NULL ,
`description` blob NOT NULL ,
PRIMARY KEY (`id`)
) TYPE = MYISAM ;
CREATE TABLE `dealers` (
`id` INT( 10 ) NOT NULL AUTO_INCREMENT ,
`title` VARCHAR( 255 ) NOT NULL ,
PRIMARY KEY (`id`)
) TYPE = MYISAM ;



Similar Posts

Comments

Name (required)

Email (required)

Website

Speak your mind

1 Comment so far

  1. adhunic on March 29, 2008 7:42 am

    it works like a charm! thanx!

Sponsors




Links