Forum Moderators: open

Message Too Old, No Replies

MySQL error -probably easy for you

         

Awful newbie

12:39 am on Sep 29, 2007 (gmt 0)

10+ Year Member



Hello! I have a problem installing db-definitions on a
MySQL 3.08. Could anyone please help me? I get this error:

You have an error in your SQL syntax near '(5000) NOT NULL, `extcontent` MEDIUMTEXT(95000) NOT NULL, `author` VARCHAR(70)' at line 1

Here is the SQL:

$sql1 = 'CREATE TABLE `archnews` ('
. ' `id` INT(255) NOT NULL AUTO_INCREMENT PRIMARY KEY, '
. ' `title` VARCHAR(70) NOT NULL, '
. ' `subtitle` VARCHAR(70) NOT NULL, '
. ' `content` MEDIUMTEXT(5000) NOT NULL, '
. ' `extcontent` MEDIUMTEXT(95000) NOT NULL, '
. ' `author` VARCHAR(70) NOT NULL, '
. ' `date` VARCHAR(70) NOT NULL, '
. ' `cat` VARCHAR(170) NOT NULL'
. ' )'
. ' TYPE = innodb;';

$result1 = mysql_query($sql1)
or die (mysql_error());

eelixduppy

1:39 am on Sep 29, 2007 (gmt 0)



Nothing should come after medium text like you have it and you don't need the semicolon in the query if you are running it through the php mysql_query function. Here is what it should look like:

$sql1 = 'CREATE TABLE `archnews` ('
. ' `id` INT(255) NOT NULL AUTO_INCREMENT PRIMARY KEY, '
. ' `title` VARCHAR(70) NOT NULL, '
. ' `subtitle` VARCHAR(70) NOT NULL, '
. ' `content` MEDIUMTEXT NOT NULL, '
. ' `extcontent` MEDIUMTEXT NOT NULL, '
. ' `author` VARCHAR(70) NOT NULL, '
. ' `date` VARCHAR(70) NOT NULL, '
. ' `cat` VARCHAR(170) NOT NULL'
. ' )'
. ' TYPE = innodb';

Refer to the create table syntax [dev.mysql.com] if you still need further information. You will see that mediumtext can take a binary value after it.

good luck :)

Awful newbie

8:44 am on Oct 3, 2007 (gmt 0)

10+ Year Member



Thank you very much - this solved it all! :-)