please help me on this topic with sample code.thanks

What kind of database are you using? What kind of backup are you trying to create?

Niek

just use phpmyadmin

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 = '*'

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.