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.

Flimzy
  • 68,325
  • 15
  • 126
  • 165
Howdy_McGee
  • 10,036
  • 28
  • 103
  • 179

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,113
  • 8
  • 64
  • 63
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
  • 9,946
  • 6
  • 47
  • 54
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
  • 25,256
  • 7
  • 48
  • 70