Hi,

I know this is 6 years old post, but if you want a fix for a 6 years old post, please read below.

Here is a good tutorial . It is an old one, but I will give you the fix for it.

copy the code shown on david's website and find this

//cycle through

right below that line add

$return = '';

scroll down the page and look for while loop as shown below..

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].'"' ; 

                } 

change the above codes to this

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] = preg_replace("#\n#", "\\n", $row[$j]);

        if (isset($row[$j])){

                $return.= '"'.$row[$j].'"' ; } else { $return.= '""'; 
        }
        if ($j<($num_fields-1)){ 
                $return.= ','; 
        }
    }

    $return.= ");\n";
}

Save the modified codes and you are done.

Don't forget to call the function and provide your database credentials.

/* backup the db OR just a table */
function backup_tables($host,$user,$pass,$name,$tables = '*')

DO NOT! Change the $tables = '*'

Edited 2 Years Ago by veedeoo: info added.

This article has been dead for over six months. Start a new discussion instead.