hadq
05-09-2005, 05:30
Tôi muốn Backup diễn đàn VBB305 mà không được, tôi đã backup file *.sql về máy rồi, đã tham khảo một số file dùng để Backup nhưng không đuợc lỗi là thế này anh em nào biết chỉ giúp tôi với http://www.doquyha.com/diendan/phuchoi.php
Code file phuchoi.php là thế này:
<?php
$db_host = "localhost";
$db_user = "sql";
$db_pass = "thaiha";
$db_name = "msql";
$link = @mysql_connect($db_h ost, $db_user, $db_pass);
mysql_select_db($db_ name, $link);
$file="vbulletin.sql";
$ndfile = file($file);
$type="NONE";
$drop_a=array();
$table_q=array();
$data_q=array();
$tables_q=0;
echo "Xin cho doi trong giay lat...<br>";
foreach($ndfile as $line) {
$line=chop($line);
if ($type=="NONE") {
if(strtolower(substr ($line,0,6))=="insert") {
$data_q[]=substr($line,0,strl en($line)-1);
} elseif(strtolower(su bstr($line,0,6))=="create") {
$type="TABLE";
$table_q[$tables_q]=$line."\n";
} elseif(strtolower(su bstr($line,0,4))=="drop") {
$type="NONE";
array_push($drop_a, $line);
}
} elseif ($type=="TABLE") {
if(strtolower(substr ($line,0,1))==")") {
$type="NONE";
$table_q[$tables_q] .= substr($line,0,strle n($line)-1)."\n";
$tables_q++;
} else {
$table_q[$tables_q] .= $line."\n";
}
}
}
$sql_error=0;
foreach($drop_a as $q_data) {
if($q_data != "") {
$q=mysql_query($q_da ta);
if($q == 0) $sql_error=1;
}
}
foreach($table_q as $q_data) {
if($q_data != "") {
$q=mysql_query($q_da ta);
if($q == 0) $sql_error=1;
}
}
foreach($data_q as $q_data) {
if($q_data != "") {
$q=mysql_query($q_da ta);
if($q == 0) $sql_error=1;
}
}
if($sql_error==1) {
echo "Da co loi !<br>Vui long kiem tra lai.";
echo mysql_error();
} else {
echo "Chuc mung ban! Da cap nhat thanh cong.<br>\n";
echo "Cap nhat <b>".sizeof($table_q)."</b> tables , va <b>".sizeof($data_q)."</b> fields.";
}
print("<br><br><br><center>Carl Johnson</center> ");
?>
Code file phuchoi.php là thế này:
<?php
$db_host = "localhost";
$db_user = "sql";
$db_pass = "thaiha";
$db_name = "msql";
$link = @mysql_connect($db_h ost, $db_user, $db_pass);
mysql_select_db($db_ name, $link);
$file="vbulletin.sql";
$ndfile = file($file);
$type="NONE";
$drop_a=array();
$table_q=array();
$data_q=array();
$tables_q=0;
echo "Xin cho doi trong giay lat...<br>";
foreach($ndfile as $line) {
$line=chop($line);
if ($type=="NONE") {
if(strtolower(substr ($line,0,6))=="insert") {
$data_q[]=substr($line,0,strl en($line)-1);
} elseif(strtolower(su bstr($line,0,6))=="create") {
$type="TABLE";
$table_q[$tables_q]=$line."\n";
} elseif(strtolower(su bstr($line,0,4))=="drop") {
$type="NONE";
array_push($drop_a, $line);
}
} elseif ($type=="TABLE") {
if(strtolower(substr ($line,0,1))==")") {
$type="NONE";
$table_q[$tables_q] .= substr($line,0,strle n($line)-1)."\n";
$tables_q++;
} else {
$table_q[$tables_q] .= $line."\n";
}
}
}
$sql_error=0;
foreach($drop_a as $q_data) {
if($q_data != "") {
$q=mysql_query($q_da ta);
if($q == 0) $sql_error=1;
}
}
foreach($table_q as $q_data) {
if($q_data != "") {
$q=mysql_query($q_da ta);
if($q == 0) $sql_error=1;
}
}
foreach($data_q as $q_data) {
if($q_data != "") {
$q=mysql_query($q_da ta);
if($q == 0) $sql_error=1;
}
}
if($sql_error==1) {
echo "Da co loi !<br>Vui long kiem tra lai.";
echo mysql_error();
} else {
echo "Chuc mung ban! Da cap nhat thanh cong.<br>\n";
echo "Cap nhat <b>".sizeof($table_q)."</b> tables , va <b>".sizeof($data_q)."</b> fields.";
}
print("<br><br><br><center>Carl Johnson</center> ");
?>