Hye guys, sorry, can anyone let me know why this code is not function in IE,but it doing great in chrome.
Thanks in advance! ;)
<?php //include("Connection.php");
backup_tables('localhost','root','1234','leave');
/* backup the db OR just a table */
function backup_tables($host,$user,$pass,$name,$tables = '*')
{
$link = mysql_connect($host,$user,$pass);
mysql_select_db($name,$link);
//get all of the tables
if($tables == '*')
{
$tables = array();
$result = mysql_query('SHOW TABLES');
while($row = mysql_fetch_row($result))
{
$tables[] = $row[0];
}
}
else
{
$tables = is_array($tables) ? $tables : explode(',',$tables);
}
//cycle through
foreach($tables as $table)
{
$result = mysql_query("SELECT * FROM ".$table);
$num_fields = mysql_num_fields($result);
$return.= 'DROP TABLE '.$table.';';
$row2 = mysql_fetch_row(mysql_query('SHOW CREATE TABLE '.$table));
$return.= "\n\n".$row2[1].";\n\n";
for ($i = 0; $i < $num_fields; $i++)
{
while($row = mysql_fetch_row($result))
{
$return.= '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])) { $return.= '"'.$row[$j].'"' ; } else { $return.= '""'; }
if ($j<($num_fields-1)) { $return.= ','; }
}
$return.= ");\n";
}
}
$return.="\n\n\n";
}
//save file
$filename = 'Leave_'.date("Y-m-d").'-'.'.sql';
Header("Content-type: application-download");
Header("Content-Disposition: attachment; filename=$filename");
echo $return;
}
?>
and this is the error i got
****
Warning: mysql_num_fields(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\leave\leave\export.php on line 33**
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\leave\leave\export.php on line 36
**
**Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\leave\leave\export.php:33) in C:\AppServ\www\leave\leave\export.php on line 59
**
Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\leave\leave\export.php:33) in C:\AppServ\www\leave\leave\export.php on line 60
DROP TABLE biro; CREATE TABLE biro
( biro_id
int(11) NOT NULL auto_increment, name
varchar(100) NOT NULL, email
varchar(50) NOT NULL, branch
varchar(20) NOT NULL,****