ngreenwood6 Posted December 3, 2008 Share Posted December 3, 2008 I have the following code: <?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 '0000-00-00 00:00:00', date_published datetime NOT NULL default '0000-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; $result = 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 '0000-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; $result = 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 '', password varchar(50) NOT NULL default '', name varchar(100) NOT NULL default '', access_lvl tinyint(4) NOT NULL default '1', PRIMARY KEY (user_id), UNIQUE KEY uniq_email (email) ) EOS; $result = mysql_query($sql) or die(mysql_error()); $adminemail = "[email protected]"; $adminpass = "admin"; $adminname = "Admin"; $sql = "INSERT IGNORE INTO cms_users " . "VALUES (NULL, '$adminemail', '$adminpass', '$adminname', 3)"; $result = mysql_query($sql) or die(mysql_error()); echo "<html><head><title>CMS Tables Created</title></head></body>"; echo "CMS Tables Created. Here is your initial login information:\n"; echo "<ul><li><strong>login</strong>: " . $adminemail . "</li>\n"; echo "<li><strong>password</strong>: " . $adminpass . "</li>\n"; echo "<a href=\"login.php\">Login</a> to the site now."; echo "</body></html>"; ?> But I am getting the following 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 'EOS; = mysql_query() or die(mysql_error()); = "INSERT IGNORE INTO cms_' at line 6 Does anyone know what I am doing wrong because I just cant seem to figure it out. Link to comment https://forums.phpfreaks.com/topic/135387-solved-mysql-query/ Share on other sites More sharing options...
ngreenwood6 Posted December 3, 2008 Author Share Posted December 3, 2008 Nevermind I just figured it out. There was a space before the ending EOS. Thanks anyways Link to comment https://forums.phpfreaks.com/topic/135387-solved-mysql-query/#findComment-705171 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.