Jump to content
xisto Community
Sign in to follow this  
Arne-Christian

Error Importing Sql Query Via Php Works in PHPmyAdmin

Recommended Posts

function sql()	{		$fp = fopen("sql.sql","r");		$sql = fread($fp,filesize("sql.sql"));		fclose($fp);		return $sql;	}

Thats $this->sql and here is the other source

function insert_sql()	{	if($_GET['insert'])  {		$template = new template;		$db = new db;		$db->connect();		$query = $this->sql();				$query = $db->query($query) or die("Error!: " . mysql_error());		return $query;		$return = "<div align=\"center\"> <br>	  <table width=\"579\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\">		  <tr>			  <td width=\"577\" class=\"header\"><div align=\"center\" ><strong>Create User </strong></div></td>		  </tr>			<tr>			  <td class=\"footer\"><br /><label>				<div align=\"center\"><strong>17</strong> Tables has been insert to MySQL Database </div>			  </label><br /></td>			</tr>		  </table>		  <br>	  </div>";	  #return $return;	}	elseif(!$_GET['insert']) {		$return = "<div align=\"center\"><table width=\"579\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\">		  <tr>			  <td width=\"577\" class=\"header\"><div align=\"center\" ><strong>Information </strong></div></td>		  </tr>			<tr>			  <td class=\"footer\"><br /><label>				<div align=\"center\">Click this button to start insert the SQL Tables				  <input type=\"submit\" name=\"Submit\" value=\"Submit\" onClick=\"java script:location.href='install.php?do=2&insert=true';\" />				</div>			  </label><br /></td>			</tr>		  </table></div>";		  return $return;		 }	}

Any ideas how to fix it, oh and here is the SQL query:

DROP TABLE IF EXISTS `eb_badword`;CREATE TABLE `eb_badword` (  `bid` int(15) NOT NULL auto_increment,  `text` varchar(225) NOT NULL,  PRIMARY KEY  (`bid`)) ENGINE=MyISAM;DROP TABLE IF EXISTS `eb_category`;CREATE TABLE `eb_category` (  `id` int(15) NOT NULL auto_increment,  `category` varchar(225)  NOT NULL,  PRIMARY KEY  (`id`)) ENGINE=MyISAM;INSERT INTO `eb_category` VALUES (1, 'Test Category');DROP TABLE IF EXISTS `eb_forums`;CREATE TABLE `eb_forums` (  `id` int(4) NOT NULL auto_increment,  `cid` int(4) NOT NULL,  `title` varchar(255)  NOT NULL,  `description` varchar(255)  NOT NULL,  PRIMARY KEY  (`id`)) ENGINE=MyISAM;INSERT INTO `eb_forums` VALUES (1, 1, 'Test forum', 'EvilBoard -> Test forum');DROP TABLE IF EXISTS `eb_group`;CREATE TABLE `eb_group` (  `g_id` int(15) NOT NULL auto_increment,  `name` varchar(225)  NOT NULL,  `clr` varchar(225)  NOT NULL,  `inf` varchar(225)  NOT NULL,  `status` enum('open','closed')  NOT NULL,  `u_id` varchar(225)  NOT NULL,  PRIMARY KEY  (`g_id`)) ENGINE=MyISAM;DROP TABLE IF EXISTS `eb_group_mem`;CREATE TABLE `eb_group_mem` (  `id` int(15) NOT NULL auto_increment,  `grp_id` varchar(225)  NOT NULL,  `userid` varchar(225)  NOT NULL,  `admin` enum('normal','admin')  NOT NULL default 'normal',  PRIMARY KEY  (`id`)) ENGINE=MyISAM;DROP TABLE IF EXISTS `eb_group_val`;CREATE TABLE `eb_group_val` (  `u_id` varchar(225)  NOT NULL,  `val_id` varchar(225)  NOT NULL,  `g_id` varchar(225)  NOT NULL) ENGINE=MyISAM;DROP TABLE IF EXISTS `eb_members`;CREATE TABLE `eb_members` (  `userid` int(25) NOT NULL auto_increment,  `first_name` varchar(25)  NOT NULL default '',  `last_name` varchar(25)  NOT NULL default '',  `email_address` varchar(25)  NOT NULL default '',  `username` varchar(25)  NOT NULL default '',  `password` varchar(255)  NOT NULL default '',  `info` text  NOT NULL,  `user_level` enum('0','1','2','3')  NOT NULL default '0',  `signup_date` datetime NOT NULL default '0000-00-00 00:00:00',  `last_login` datetime NOT NULL default '0000-00-00 00:00:00',  `activated` enum('0','1')  NOT NULL default '0',  PRIMARY KEY  (`userid`)) ENGINE=MyISAM  COMMENT='Membership Information';DROP TABLE IF EXISTS `eb_moderator`;CREATE TABLE `eb_moderator` (  `mid` mediumint(8) NOT NULL auto_increment,  `forum_id` int(5) NOT NULL,  `member_name` varchar(32)  NOT NULL,  `member_id` mediumint(8) NOT NULL,  `edit_post` smallint(1) NOT NULL,  `delete_post` smallint(1) NOT NULL,  `view_ip` smallint(1) NOT NULL,  PRIMARY KEY  (`mid`)) ENGINE=MyISAM  COMMENT='EvilBoard Moderators';DROP TABLE IF EXISTS `eb_pm`;CREATE TABLE `eb_pm` (  `id` int(15) NOT NULL auto_increment,  `message` text  NOT NULL,  `title` varchar(225)  NOT NULL,  `from` varchar(225)  NOT NULL,  `to` varchar(225)  NOT NULL,  `postdate` datetime NOT NULL,  `UserID` varchar(155)  NOT NULL,  PRIMARY KEY  (`id`)) ENGINE=MyISAM;DROP TABLE IF EXISTS `eb_post`;CREATE TABLE `eb_post` (  `message` text  NOT NULL,  `postdate` datetime NOT NULL,  `UserID` varchar(225)  NOT NULL,  `Username` varchar(225)  NOT NULL,  `PostID` int(15) NOT NULL auto_increment,  `TopicID` varchar(225)  NOT NULL,  `ForumID` varchar(225)  NOT NULL,  `title` varchar(225)  NOT NULL,  `user_ip` varchar(32)  NOT NULL,  PRIMARY KEY  (`PostID`)) ENGINE=MyISAM;INSERT INTO `eb_post` VALUES ('<p>If you are able to read this post, EvilBoard has been successfully installed on your webserver, you can remove this topic, forum, and even the category from your admin panel.</p><p>A test of emoticons:</p><p><img src=\'Emoticons/1/smiley-cool.gif\' alt=\'\' /><img src=\'Emoticons/1/smiley-cry.gif\' alt=\'\' /><img src=\'Emoticons/1/smiley-embarassed.gif\' alt=\'\' /><img src=\'Emoticons/1/smiley-innocent.gif\' alt=\'\' /><img src=\'Emoticons/1/smiley-yell.gif\' alt=\'\' /><img src=\'Emoticons/1/smiley-wink.gif\' alt=\'\' /><img src=\'Emoticons/1/smiley-undecided.gif\' alt=\'\' /><img src=\'Emoticons/1/smiley-tongue-out.gif\' alt=\'\' /><img src=\'Emoticons/1/smiley-surprised.gif\' alt=\'\' /><img src=\'Emoticons/1/smiley-smile.gif\' alt=\'\' /><img src=\'Emoticons/1/smiley-sealed.gif\' alt=\'\' /><img src=\'Emoticons/1/smiley-money-mouth.gif\' alt=\'\' /><img src=\'Emoticons/1/smiley-laughing.gif\' alt=\'\' /><img src=\'Emoticons/1/smiley-kiss.gif\' alt=\'\' /></p><p>If you can see 14 pictures here, all the Emoticons are working.</p><p>Enjoy EvilBoard, and please submit bugs at cs-gladz.com/evilboard/; (Forum: Report EvilBoard Bugs)</p><p>~ The EvilBoard Group </p>', '2006-09-28 22:40:46', '0', 'The EvilBoard Group', 1, '1', '1', 'Test Topic', '127.0.0.1');DROP TABLE IF EXISTS `eb_profile`;CREATE TABLE `eb_profile` (  `name` varchar(255)  NOT NULL,  `logo` varchar(255)  NOT NULL,  `rank` varchar(255)  NOT NULL,  `email` varchar(255)  NOT NULL,  `msn` varchar(255)  NOT NULL,  `yahoo` varchar(255)  NOT NULL,  `icq` varchar(255)  NOT NULL,  `aim` varchar(255)  NOT NULL,  `location` varchar(255)  NOT NULL,  `website` varchar(255)  NOT NULL,  `intr` text  NOT NULL,  `alias` varchar(255)  NOT NULL,  `age` varchar(255)  NOT NULL,  `mpad` varchar(255)  NOT NULL,  `hps` varchar(255)  NOT NULL,  `mouse` varchar(255)  NOT NULL,  `cpu` varchar(255)  NOT NULL,  `mboard` varchar(255)  NOT NULL,  `ram` varchar(255)  NOT NULL,  `monit` varchar(255)  NOT NULL,  `gpcard` varchar(255)  NOT NULL,  `id` int(15) NOT NULL auto_increment,  `sig` text  NOT NULL,  PRIMARY KEY  (`id`)) ENGINE=MyISAM;DROP TABLE IF EXISTS `eb_psettings`;CREATE TABLE `eb_psettings` (  `UserID` int(155) NOT NULL auto_increment,  `h_mail` enum('0','1')  NOT NULL,  `s_pm` enum('0','1')  NOT NULL,  `s_update` enum('0','1')  NOT NULL,  `p_sig` enum('0','1')  NOT NULL,  `p_avy` enum('0','1')  NOT NULL,  PRIMARY KEY  (`UserID`)) ENGINE=MyISAM;DROP TABLE IF EXISTS `eb_ranks`;CREATE TABLE `eb_ranks` (  `rid` int(15) NOT NULL auto_increment,  `rname` varchar(225)  NOT NULL,  PRIMARY KEY  (`rid`)) ENGINE=MyISAM;INSERT INTO `eb_ranks` VALUES (1, 'Member');INSERT INTO `eb_ranks` VALUES (2, 'Moderator');INSERT INTO `eb_ranks` VALUES (3, 'Administrator'); DROP TABLE IF EXISTS `eb_settings`;CREATE TABLE `eb_settings` (  `homepage` varchar(225)  NOT NULL,  `forum_name` varchar(225)  NOT NULL,  `eb_version` varchar(10)  NOT NULL,  `register` enum('0','1','2')  NOT NULL,  `e_domain` varchar(225)  NOT NULL,  `path` text  NOT NULL,  `post_per_page` mediumint(15) NOT NULL default '20',  `topic_per_page` mediumint(15) NOT NULL default '25',  `members_per_page` mediumint(15) NOT NULL default '25',  `badword_replace` varchar(1)  NOT NULL default '*') ENGINE=MyISAM;DROP TABLE IF EXISTS `eb_smiley`;CREATE TABLE `eb_smiley` (  `cmd` text  NOT NULL,  `img` text  NOT NULL,  `id` int(15) NOT NULL auto_increment,  PRIMARY KEY  (`id`)) ENGINE=MyISAM;INSERT INTO `eb_smiley` VALUES (':cool:', 'smiley-cool.gif', 10);INSERT INTO `eb_smiley` VALUES (':cry:', 'smiley-cry.gif', 9);INSERT INTO `eb_smiley` VALUES (':embrassed:', 'smiley-embarassed.gif', 14);INSERT INTO `eb_smiley` VALUES (':angel:', 'smiley-innocent.gif', 12);INSERT INTO `eb_smiley` VALUES (':yell:', 'smiley-yell.gif', 15);INSERT INTO `eb_smiley` VALUES (':wink:', 'smiley-wink.gif', 16);INSERT INTO `eb_smiley` VALUES (':uhh:', 'smiley-undecided.gif', 17);INSERT INTO `eb_smiley` VALUES (':p', 'smiley-tongue-out.gif', 18);INSERT INTO `eb_smiley` VALUES (':surprised:', 'smiley-surprised.gif', 19);INSERT INTO `eb_smiley` VALUES (':smile:', 'smiley-smile.gif', 20);INSERT INTO `eb_smiley` VALUES (':sealed:', 'smiley-sealed.gif', 21);INSERT INTO `eb_smiley` VALUES (':money-crazy:', 'smiley-money-mouth.gif', 22);INSERT INTO `eb_smiley` VALUES (':haha:', 'smiley-laughing.gif', 23);INSERT INTO `eb_smiley` VALUES (':kiss:', 'smiley-kiss.gif', 24);DROP TABLE IF EXISTS `eb_topic`;CREATE TABLE `eb_topic` (  `UserID` varchar(225)  NOT NULL,  `title` varchar(225)  NOT NULL,  `TopicID` int(225) NOT NULL auto_increment,  `replays` varchar(225)  NOT NULL,  `desc` varchar(225)  NOT NULL,  `Username` varchar(225)  NOT NULL,  `ForumID` varchar(225)  NOT NULL,  PRIMARY KEY  (`TopicID`)) ENGINE=MyISAM;INSERT INTO `eb_topic` VALUES ('1', 'Test Topic', 1, '0', '', 'The EvilBoard Group', '1');

And the error is:

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 '; CREATE TABLE `eb_badword` ( `bid` int(15) NOT NULL auto_increment, `tex' at line 1

Share this post


Link to post
Share on other sites

I think the problem is the ' character before and after the table name...get those out of your code and try again..tell back if it works:)

Share this post


Link to post
Share on other sites

CREATE TABLE `eb_badword` (

`bid` int(15) NOT NULL auto_increment,

`text` varchar(225) NOT NULL,

PRIMARY KEY (`bid`)

) ENGINE=MyISAM;") or die(mysql_error());

 

I`m talking about those (red characters:) )..my queries have no such chars, but I tried putting these before and after the table name and it gave an error..so just try getting thost chars out..:)

Edited by hts (see edit history)

Share this post


Link to post
Share on other sites

These characters are allowed and infact they act as a distinguishing factor if the name of the table or field resembles a name of a MySQL function like SUM .It is advisable to use it rather.By the way Arne-Christian you have used a class in PHP but not given the entire class and gave only the functions.Please post the entire class.

Share this post


Link to post
Share on other sites
  electron said:

These characters are allowed and infact they act as a distinguishing factor if the name of the table or field resembles a name of a MySQL function like SUM .It is advisable to use it rather.

By the way Arne-Christian you have used a class in PHP but not given the entire class and gave only the functions.
Please post the entire class.


hmm..then there`s something wrong with my mysql queries :) ..as I told you, I get an error when using ' '...I`ll check this out :P..thank you for the information

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.