Hi. I have a .sql file which contains about 200 lines of queries. I know i can go to mysqlAdmin and import those queries to my newly created database. I am wondering, is there a way to run all those queries using php codes? I know i can do mysql_query(parameter), but I dont know how to bump all queries from my file into that parameter, so that i only need to use mysql_query method once. thanks in advance.
Why you need to spend time on creating such a thing, if you can do this in a few minutes through the cpanel ?
I have never made one. I have looked at a lot of install scripts. Other than making the DB connection and setting up the query they are nothing more than a sql dump. Here are two fragments, clearly labeled that do the same thing (different DB). A sample from a php install script: $q1 = "DROP TABLE IF EXISTS `tbl_name` "; mysql_query($q1) or die(mysql_error()." at line ". __LINE__); $q1 = "CREATE TABLE `tbl_name` ( `BannerID` smallint(5) NOT NULL auto_increment, `BannerFile` varchar(255) NOT NULL, `BannerURL` varchar(255) NOT NULL, `AltText` varchar(150) NOT NULL, `BannerType` char(4) NOT NULL, PRIMARY KEY (`BannerID`) ) AUTO_INCREMENT=5 "; mysql_query($q1) or die(mysql_error()." at line ". __LINE__); //-- Dumping data for table `tbl_name` $q1 = "INSERT INTO `tbl_name` VALUES (1, '1156033691_dsd_banner.gif', 'http://www.somesite.com/', 'Some text', 'Full')"; mysql_query($q1) or die(mysql_error()." at line ".__LINE__); $q1 = "INSERT INTO `tbl_name` VALUES (2, '1154984206_hs.gif', 'http://www.hotscripts.com/?RID=N357500', 'The Net´s largest script repository', 'Full')"; mysql_query($q1) or die(mysql_error()." at line ".__LINE__); $q1 = "INSERT INTO `tbl_name` VALUES (3, '1156033723_dsd_bnr_sml.gif', 'http://somesite.com/', 'Some text', 'Menu')"; PHP: A sample from a sql dump that would import via phpmyadmin: DROP TABLE IF EXISTS `categories`; CREATE TABLE `categories` ( `id` int(4) NOT NULL auto_increment, `category` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=110 ; -- -- Dumping data for table `categories` -- INSERT INTO `categories` VALUES (1, 'Aardvark jokes'); INSERT INTO `categories` VALUES (2, 'Accountant jokes'); INSERT INTO `categories` VALUES (3, 'Answer me this jokes'); PHP: As you can plainly see there is very little difference. Merry Christmas