Gå til innhold

feil med sql syntax - Hva gjør jeg galt?


Anbefalte innlegg

Hei..

 

Har prøvd i flere dager nå og finer ikke ut hva jeg gjør galt...

 

her er coden:

 

<?php
require_once 'conn.php';

$sql = <<<EOS
CREATE TABLE IF NOT EXISTS cms_access_levels (
access_lvl tinyint (4) NOT NULL auto_increment,
access_name varchar (50) NOT NULL default '',
PRIMARY KEY (access_lvl)
)
EOS;
$result = mysql_query($sql)
 or die (mysql_error());

$sql = "INSERT IGNORE INTO cms_access_levels " .
"VALUES (1, 'User'), ".
"(2, 'Moderator'), ".
"(3, 'Administrator')";
$result = mysql_query($sql)
 or die (mysql_error());

$sql = <<<EOS
CREATE TABLE IF NOT EXISTS cms_articles (
article_id int (11) NOT NULL auto_increment,
author_id int (11) NOT NULL default '0',
is_published tinyint(1) NOT NULL default '0',
date_submitted datetime NOT NULL default '000-00-00 00:00:00',
date_published datetime NOT NULL default '000-00-00 00:00:00',
title varchar(255) NOT NULL default '',
body mediumtext NOT NULL,
PRIMARY KEY (article_id),
KEY IdxArticle (author_id,date_submitted),
FULLTEXT KEY idxText (title,body)
)
EOS;
$results = mysql_query($sql)
 or die (mysql_error());

$sql = <<<EOS
CREATE TABLE IF NOT EXISTS cms_comments (
 comment_id int (11) NOT NULL auto_increment,
 article_id int (11) NOT NULL default '0',
 comment_date datetime NOT NULL default '000-00-00 00:00:00',
 comment_user int (11) NOT NULL default '0',
 comment_text NOT NULL,
 PRIMARY KEY (comment_id),
 KEY IdxComment (article_id)
)
EOS;
$results = mysql_query($sql)
 or die (mysql_error());

$sql = <<<EOS
CREATE TABLE IF NOT EXISTS cms_users (
 user_id int(11) NOT NULL auto_increment,
 email varchar(255) NOT NULL default '',
 passwd varchar(50) NOT NULL default '',
 name varchar(100) NOT NULL default '',
 acsess_lvl tinyint(4) NOT NULL default '1',
 PRIMARY KEY (user_id)
 UNIQUE KEY uniq_email (email)
)
EOS;
$results = mysql_query($sql)
 or die (mysql_error());

$adminemail ="[email protected]";
$adminpass ="passord";
$adminname ="navn";

$sql = "INSERT IGNORE INTO cms_users ".
      "VALUES (NULL, '$adminemail', '$adminpass', '$adminname', 3)";
$results = mysql_query($sql)
or die (mysql_error());

echo "<html><head><title>cms tables sucsesfully created</title></head><body>";
echo "CMS tables sucsessfully created. your admin-information is: \n";
echo "<ul><li><strong>Login:" .$adminemail. "</li>\n";
echo "<li><strong>Password:" .$adminpass. "</li>\n";
echo "<a href=\"login.php\">Log in</a>";
echo "</body></html>";

?>

 

feilmelding:

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 'NOT NULL, PRIMARY KEY (comment_id), KEY IdxComment (artic

 

Håper noen kan hjelpe meg ut her :blush:

Lenke til kommentar
Videoannonse
Annonse

Opprett en konto eller logg inn for å kommentere

Du må være et medlem for å kunne skrive en kommentar

Opprett konto

Det er enkelt å melde seg inn for å starte en ny konto!

Start en konto

Logg inn

Har du allerede en konto? Logg inn her.

Logg inn nå
  • Hvem er aktive   0 medlemmer

    • Ingen innloggede medlemmer aktive
×
×
  • Opprett ny...