0

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,****

2
Contributors
2
Replies
3
Views
4 Years
Discussion Span
Last Post by LastMitch
0

@eyeda

Hye guys, sorry, can anyone let me know why this code is not function in IE,but it doing great in chrome.

It's really weird question that you are asking?

If a php code doesn't work for IE, it shouldn't work for any other browsers either. Only html & css code affect browsers appears as for php code it's runs on your host server and database.

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\leave\leave\export.php on line 36
**

On line 32:

$result = mysql_query("SELECT * FROM ".$table);

You query looks funny meaning weird.

What is .$table? Is .$table a table in you db?

It should looks like this:

$result = mysql_query("SELECT * FROM table");

When you used:

 Select * From Column.

Do see where I'm getting at?

0
Select * From Table 

not Column.

Is what I'm meant. Sorry about that.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.