Firstly, I will show you my codes:
index.php:
<?php
include 'mysql.inc.php';
$mysql = new mysql;
$mysql->connect(****,****,****);
$tables = array('banned');
$mysql->export(smf,$tables);
?>
mysql.inc.php:
<?php
class mysql {
function export($db,$tcable) {
mysql_select_db($db) or die(mysql_error());
foreach($table as $t) {
$query = mysql_query("select * from $t") or die(mysql_error());
$num_fields = mysql_num_fields($query) or die(mysql_error());
$numrow = mysql_num_rows($query) or die(mysql_error());
for ($i =0; $i<$numrow; $i++) {
$result .= "INSERT INTO ".$t." VALUES(";
for($j=0; $j<$num_fields; $j++) {
$row[$j] = addslashes($row[$j]);
$row[$j] = ereg_replace("\n","\\n",$row[$j]);
if (isset($row[$j])) {
$result .= "\"$row[$j]\"";
} else {
$result .= "\"\"";
}
if ($j<($num_fields-1)) $result .= ",";
}
$result .= ");\n";
}
}
$file_name = "MySQL_Database_Backup.sql";
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=$file_name");
return $result;
}
}
?>
And if I run index.php, I get nothing. The script doesn't actually exit, but I just get no response.
However, if I change
$tables = array('banned');
to..
$tables = array();
.. I will get the file back, but obviously it is empty.
Any help would be great!
Thanks,
James.
Edited by JamesH, 14 November 2006 - 01:01 PM.
