php import larg table to phpmyadmin database

Posted by safaali on Stack Overflow See other posts from Stack Overflow or by safaali
Published on 2010-06-05T13:12:39Z Indexed on 2010/06/05 13:22 UTC
Read the original article Hit count: 154

Filed under:
|
|

hi, I am so worry :(

I dropped one of the tables from the database accidentally. fortunately, I have back-up. (I have used the "Auto backup for mysql")

The back-up of the table is stored as .txt file (56 Megabytes) on my PC.

I tried to import it by PhpMyAdmin and the import failed because the file is too large to import.

then I uploaded the file to /home/tablebk directory. I have some experiences in php. I know that I would import it with this code, but i don't know the sql statment for this import.

what is have to put as $line variable?

please help me :( :(

<?php

    $dbhost = 'localhost';          
$dbuser = 'mysite';         
$dbpw = 'password';         
$dbname = 'databasename';

$file = @fopen('country.txt', 'r');

if ($file)
{
    while (!feof($file))
    {
        $line = trim(fgets($file));
        $flag = mysql_query($line);

        if (isset($flag))
        {
            echo 'Insert Successfully<br />';
        }

        else
        {
            echo mysql_error() . '<br/>';
        }

        flush();
    }

    fclose($file);
}

echo '<br />End of File';

?>

© Stack Overflow or respective owner

Related posts about php

Related posts about sql