1

Is there something wrong with this code? I'm running MYSQL 5 I keep getting this 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 'desc BLOB, review BLOB, url BLOB )'

Here's my query:

mysql_query("CREATE TABLE videos(
                id INT NOT NULL AUTO_INCREMENT, 
                PRIMARY KEY(id),
                title VARCHAR(50),
                desc BLOB,
                review BLOB,
                url BLOB
            )
") or die(mysql_error());

It looks alright to me. At first I thought it was the "BLOB" datatype but then I tried "TEXT" and it still messed up so I'm not quite sure.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Howdy_McGee
  • 10,422
  • 29
  • 111
  • 186

3 Answers3

5

desc is a reserved keyword, you need to escape it:

mysql_query("CREATE TABLE videos(
                id INT NOT NULL AUTO_INCREMENT, 
                PRIMARY KEY(id),
                title VARCHAR(50),
                `desc` BLOB,
                review BLOB,
                url BLOB
            )
")or die(mysql_error());

For the full list of reserved keywords, see 8.3. Reserved Words

The Scrum Meister
  • 29,681
  • 8
  • 66
  • 64
1

desc ise reserved keyword for MySQL, you should cover it with backticks:

CREATE TABLE videos (
id INT NOT NULL AUTO_INCREMENT, 
`title` VARCHAR(50),
`desc` BLOB,
`review` BLOB,
`url` BLOB,
PRIMARY KEY  (`id`)
)
Emre Yazici
  • 10,136
  • 6
  • 48
  • 55
0

try with:

mysql_query("CREATE TABLE videos(
                `id` INT NOT NULL AUTO_INCREMENT, 
                PRIMARY KEY(id),
                `title` VARCHAR(50) NULL,
                `desc` BLOB NULL,
                `review` BLOB NULL,
                `url` BLOB NULL
            )
")or die(mysql_error());
Tudor Constantin
  • 26,330
  • 7
  • 49
  • 72