I have this piece of code, but I cant get it work, whats wrong with it?
$db_connection = mysql_connect("$server","$user","$pass") or die ("No DB Connection");
$db = mysql_select_db("$db",$db_connection) or die ("Couldn't select DB");
$table1 = datadump ("options");
$table2 = datadump ("tbl_users");
$content = $table1 . $table2;
function datadump ($table) {
$result .= "# Dump of $table \n";
$result .= "# Dump DATE : " . date("d-M-Y") ."\n\n";
$query = mysql_query("select * from $table");
$num_fields = @mysql_num_fields($query);
$numrow = mysql_num_rows($query);
for ($i =0; $i<$numrow; $i++) {
$result .= "INSERT INTO ".$table." 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";
}
return $result . "\n\n\n";
}
$file_name = "MySQL_Database_Backup.sql";
Header("Content-type: application/octet-stream");
Header("Content-Disposition: attachment; filename=$file_name");
echo $content;
exit;
Thanks in advance
Niklas