How do I use php to create a database with table and info using a backup file?
so far my code is
<?
header("content-type:text/plain");
$serv= mysql_connect('localhost', 'root', 'xxxx');
if($serv){
wText("Server connection created");
}
else{
wText("Server connection failed");
}
$sql ="CREATE DATABASE tf2faq";
if(@mysql_query($sql,$serv)){
wText("Database tf2faq created");
}
else{wText("Database tf2faq create failed");}
$sql = 'CREATE TABLE `tf2faq`.`loadoutitems` (`item` TEXT NULL, `class` TEXT NULL, `type` TEXT NULL, `replaces` TEXT NULL, `itempos` TEXT NULL, `modpos` TEXT NULL, `modneg` TEXT NULL, `imgurl` TEXT NULL, `notes` TEXT NULL) ENGINE = MyISAM';
mysql_query($sql,$serv);
if(@mysql_query($sql,$serv)){
wText("table loadoutitems created");
}
else{
wText("table loadoutitems create failed");
}
$sql="LOAD DATA INFILE 'loadoutitmsfx.csv' INTO TABLE `tf2faq`.'loadoutitems'";
if(@mysql_query($sql,$serv)){
wText("Data Load Passed");
}
else{
wText("Data Load Failed");
}
function wText($txt){
echo $txt . "\n";
}
?>
it fails on the LOAD DATA line, not sure why.
edit in my code i removed the "@" in there and it still says the file load failed