papillonstudios Posted August 21, 2009 Share Posted August 21, 2009 ok whats wrong with this code if i execute the queries in phpmyadmin theres no problems but when i got to do it from the browser in my install system it doesn't work. ERROR: Couldn't insert data into permissions table 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 'INSERT INTO `permissions` VALUES(2, 'admin', 1, 1, 1, 1); INSERT INTO `per' at line 2 code <?php $users = " CREATE TABLE IF NOT EXISTS `users` ( `id` int(5) NOT NULL auto_increment, `username` varchar(30) NOT NULL, `password` varchar(255) NOT NULL, `email` varchar(50) NOT NULL, `location` varchar(50) NOT NULL, `aim` varchar(30) NOT NULL, `msn` varchar(30) default NULL, `gtalk` varchar(30) NOT NULL, `ip` varchar(30) NOT NULL, `signup` varchar(30) NOT NULL, `membergroup` varchar(30) NOT NULL, `bio` varchar(400) NOT NULL, `gender` varchar(10) NOT NULL, `avatar` varchar(300) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM ;"; $permissions = " CREATE TABLE IF NOT EXISTS `permissions` ( `mg_id` int(10) NOT NULL auto_increment, `mg_name` varchar(50) NOT NULL, `editprofile` int(1) NOT NULL, `viewprofile` int(1) NOT NULL, `admin` int(1) NOT NULL, `moderate` int(1) NOT NULL, PRIMARY KEY (`mg_id`) ) ENGINE=MyISAM ;"; $addperm = " INSERT INTO `permissions` (`mg_id`, `mg_name`, `editprofile`, `viewprofile`, `admin`, `moderate`) VALUES (1, 'user', 1, 1, 0, 0), (2, 'admin', 1, 1, 1, 1), (3, 'guest', 0, 0, 0, 0), (4, 'mod', 1, 1, 0, 1); "; $info = " CREATE TABLE IF NOT EXISTS `info` ( `id` int(11) NOT NULL auto_increment, `version` varchar(50) NOT NULL, `sitename` varchar(100) NOT NULL, `siteurl` varchar(100) NOT NULL, `sitedesc` text NOT NULL, `aemail` varchar(300) NOT NULL, `atwitter` varchar(50) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM ;"; $news = " CREATE TABLE IF NOT EXISTS `news` ( `id` int(11) NOT NULL auto_increment, `title` varchar(50) NOT NULL, `username` varchar(50) NOT NULL, `date` varchar(100) NOT NULL, `body` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM ;"; $downloads = " CREATE TABLE IF NOT EXISTS `downloads` ( `id` int(11) NOT NULL auto_increment, `name` varchar(100) NOT NULL, `url` varchar(100) NOT NULL, `dldesc` text NOT NULL, `date` varchar(20) NOT NULL, `username` varchar(50) NOT NULL, `count` varchar(6) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM;"; $games = " CREATE TABLE IF NOT EXISTS `games` ( `id` int(11) NOT NULL auto_increment, `name` varchar(20) NOT NULL, `source` varchar(100) NOT NULL, `height` varchar(5000) NOT NULL, `width` varchar(5000) NOT NULL, `gamedesc` text NOT NULL, `thumbnail` varchar(100) NOT NULL default 'i/thumbnail.jpg', PRIMARY KEY (`id`) ) ENGINE=MyISAM;"; $videos = " CREATE TABLE IF NOT EXISTS `video` ( `id` int(11) NOT NULL auto_increment, `name` varchar(60) NOT NULL, `username` varchar(50) NOT NULL, `source` varchar(50) NOT NULL, `embed` text NOT NULL, `videodesc` text NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM ;"; mysql_query($users) or die ('Couldn\'t create users table ' . mysql_error()); mysql_query($permissions) or die ('Couldn\'t create permissions table ' . mysql_error()); mysql_query($addperm) or die ('Couldn\'t insert data into permissions table ' . mysql_error()); mysql_query($info) or die ('Couldn\'t create info table ' . mysql_error()); mysql_query($news) or die ('Couldn\'t create news table ' . mysql_error()); mysql_query($downloads) or die ('Couldn\'t create downloads table' . mysql_error()); mysql_query($games) or die ('Couldn\'t create games table' . mysql_error()); mysql_query($videos) or die ('Couldn\'t create videos table' . mysql_error()); ?> Quote Link to comment https://forums.phpfreaks.com/topic/171338-solved-mysql-error/ Share on other sites More sharing options...
MadTechie Posted August 21, 2009 Share Posted August 21, 2009 try $addperm = " INSERT INTO `permissions` (`mg_name`, `editprofile`, `viewprofile`, `admin`, `moderate`) VALUES ('user', 1, 1, 0, 0), ('admin', 1, 1, 1, 1), ('guest', 0, 0, 0, 0), ('mod', 1, 1, 0, 1); "; Quote Link to comment https://forums.phpfreaks.com/topic/171338-solved-mysql-error/#findComment-903582 Share on other sites More sharing options...
papillonstudios Posted August 21, 2009 Author Share Posted August 21, 2009 it worked what did you change? Quote Link to comment https://forums.phpfreaks.com/topic/171338-solved-mysql-error/#findComment-903589 Share on other sites More sharing options...
MadTechie Posted August 21, 2009 Share Posted August 21, 2009 Well as `mg_id` int(10) is an auto_increment so you don't need to manually set them.. so i removed them (you could just sent them to null) OR you could set auto number to start at 5 then set 1-4 Quote Link to comment https://forums.phpfreaks.com/topic/171338-solved-mysql-error/#findComment-903602 Share on other sites More sharing options...
papillonstudios Posted September 3, 2009 Author Share Posted September 3, 2009 ok Quote Link to comment https://forums.phpfreaks.com/topic/171338-solved-mysql-error/#findComment-911959 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.