berserk 60 Junior Poster

here is the upload.php

?php

    require ('dbconnect.php'); // connect to database

    // initial database stuff

        $file = "data.txt";
        $file_handle = fopen($file, "r");

        mysql_query("TRUNCATE TABLE Numbers") or die("MySQL Error: " . mysql_error()); //Delete the existing rows
        while (($data = fgetcsv($file_handle, 1000, ",")) !== FALSE)
        {
            foreach($data as $row)
            {
                $query="INSERT into numbdata(Numb) values($row)";
                mysql_query($query) or die(mysql_error()); 
            }
        }

fclose($file_handle);


echo "Done!";
/*


    // Form to upload a new file, make sure you get the "enctype" or it won't work
    echo "
        <form  enctype='multipart/form-data' name='fileupload' action='upload.php' method='POST'>

            <input type='file' name='uploadedfile'> 
            <input type='submit' name='upload' value='Upload File'>

        </form>
    ";
*/
?>

and here is the dbconnect.php

<?php
    $host = "";        // the host your database server is on, probably localhost
    $username = "";        // Database Username, if you are doing this locally and haven't set one it will probably be "root"
    $password = ;            // Database Password, if you are doing this locally and haven't set one it will probably be NULL 
    $database = "Numbers";    // The name of the database you want to use.

    // Try to connect to mysql
    mysql_connect($host, $username, $password) or die ("Could not connect to database");  

    // Try to select the database 
    mysql_select_db($database) or die ("Could not select database");    
?>
tapananand commented: Check if you did completely what was asked before posting here. You updated only one line and not the other. +0