Jump to content

[SOLVED] MYSQL ERROR


papillonstudios

Recommended Posts

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());

?>

Link to comment
https://forums.phpfreaks.com/topic/171338-solved-mysql-error/
Share on other sites

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);
                              ";

Link to comment
https://forums.phpfreaks.com/topic/171338-solved-mysql-error/#findComment-903582
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.