FezEvils Posted January 7, 2009 Share Posted January 7, 2009 hello every1, this week i'm facing problem with how to restore mysql.. before this , i succesfully write script on how to backup db.. so the problem is how to insert multiple sql to mysql not through web page, not in phpmyadmin. mysql file contain sql : DROP TABLE IF EXISTS `address`; CREATE TABLE `address` ( `a_add` varchar(255) collate latin1_general_ci default NULL, `a_postcode` varchar(255) collate latin1_general_ci default NULL, `a_city` varchar(255) collate latin1_general_ci default NULL, `a_state` varchar(255) collate latin1_general_ci default NULL, `a_phone` varchar(255) collate latin1_general_ci default NULL, `a_email` varchar(255) collate latin1_general_ci NOT NULL default '', `a_fax` varchar(255) collate latin1_general_ci default NULL, PRIMARY KEY (`a_email`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci; INSERT INTO address VALUES ('Perbadanan Bioteknologi & Biodiversiti Negeri Johor, Blok 2, Pusat Inovasi, UTM-MTDC, Technovation Park, Skudai ', '81300', 'Johor Bharu', 'Johor', '075207810', '[email protected]', '075207811'); INSERT INTO address VALUES ('', '', '', '', '', '[email protected]', ''); INSERT INTO address VALUES ('', '', '', '', '', '[email protected]', ''); INSERT INTO address VALUES ('No.39 Jalan Pulai 41', '81300', 'SKUDAI', 'JOHOR', '075522684', '[email protected]', '075522684'); so my script is : $theData = stripslashes ($_POST['sql']); $theData = preg_replace('/\s\s+/', ' ', $theData); echo $x = "$theData"; $q="$x"; $r=mysql_db_query($database_biota,$q) or die ("<html><script language='javascript'>alert('Restore DB SQL Gagal'),history.go(-1)</script></html>"); echo "<script>window.location.href=\"page.php?pageid=admin_setting\"</script>"; -------------------- error are in variable $q which contains $x (sql script) script fail to insert into db because $q only execute 1 sql command in one time because of the delimiter ";" so please help me.. tq Link to comment https://forums.phpfreaks.com/topic/139795-how-to-restore-mysql-db/ Share on other sites More sharing options...
trq Posted January 7, 2009 Share Posted January 7, 2009 php's mysql_query functions are unable to process mutlitple queries, you'll need to do this via mysql's command line interface. Link to comment https://forums.phpfreaks.com/topic/139795-how-to-restore-mysql-db/#findComment-731358 Share on other sites More sharing options...
FezEvils Posted January 7, 2009 Author Share Posted January 7, 2009 it is any other way to solve this problem beside using command line..? i'm trying to do the same function in phpmyadmin under IMPORT tab... Link to comment https://forums.phpfreaks.com/topic/139795-how-to-restore-mysql-db/#findComment-731368 Share on other sites More sharing options...
trq Posted January 7, 2009 Share Posted January 7, 2009 You could execute the command line commands via php's exec family of functions. Why don't you take a look at how phpmyadmin do it? Link to comment https://forums.phpfreaks.com/topic/139795-how-to-restore-mysql-db/#findComment-731372 Share on other sites More sharing options...
FezEvils Posted January 7, 2009 Author Share Posted January 7, 2009 um... that a good idea.. tq for the exec() function. but my problem is now solved.. visit this article on http://d15.biz/blog/2006/12/09/restore-mysql-dump-using-php/ for the solution.. tq thrope Link to comment https://forums.phpfreaks.com/topic/139795-how-to-restore-mysql-db/#findComment-731397 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.