Jump to content

How to restore mysql db?


FezEvils

Recommended Posts

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

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.