Mar
24
Cook up Web sites fast with CakePHP MySQL Syntax Problem
March 24, 2008 |
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
- CakePHP - the right syntax to use near ‘generateList’
- Cook up Web sites fast with CakePHP ACL Problem
- CakePHP Solution for Could not open input file: acl.php
- CakePHP Solution for Warning: Cannot modify header information - headers already sent
- Cook up Web sites fast with CakePHP knownusers.thtml
- Cook up Web sites fast with CakePHP - Invalid Login
- CakePHP acl delete aro Correct Systax
- Backup Export MySQL Database Using PHP
- MySQL Default Schema
Comments
1 Comment so far



































it works like a charm! thanx!