PHP/MySQL INSERT, tab delimited file

hello all,

I have the following code and it seems right to me, but it isnt actually performing the insert.  any ideas?

CODE
------------------------

<?  
$server = mysql_connect('localhost', 'root') or die(mysql_error());
mysql_select_db ('paper') or die (mysql_error());

$readfile = file("customers.txt");

for ($k=0; $k<=count($readfile)-1; $k++) {
    $fields = split("\t",$readfile[$k]);
    //echo("$fields[0] and $fields[1] and $fields[3] and $fields[4] and $fields[5] and $fields[6] and $fields[7] and $fields[8] and $fields[9] and $fields[10] and $fields[11] and $fields[12] and $fields[13]<br>");
            
            $query = "INSERT INTO customers VALUES ('$fields[0]','$fields[1]','$fields[2]','$fields[3]','$fields[4]','$fields[5]','$fields[6]','$fields[7]','$fields[8]','$fields[9]','$fields[10]','$fields[11]','$fields[12]','$fields[13]')";
            //echo $query;
            mysql_query($query);
            mysql_close();

            die(mysql_error());
}
?>

---------------------------
END CODE
LVL 13
flow79Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RoonaanCommented:
Try: mysql_query($query) or die(mysql_error());

-r-
sdmdjCommented:
Give this a go, works fine here.

Note: I've left my source as it was, so you'll need to change any passwords or usernames back to your own. You also might want to name your database columns a little better than in my example! :-)

<?php
$server=@mysql_connect("localhost","root","mysql") or die(mysql_error());

@mysql_select_db("test",$server) or die(mysql_error());

$readfile=file("customers.txt");

for($k=0; $k<=count($readfile)-1; $k++)
{
      $fields=explode("\t",$readfile[$k]);

      $query="insert into customers (id,field1,field2,field3,field4,field5,field6,field7,field8,field9,field10,field11,field12,field13,field14) VALUES (null,'$fields[0]','$fields[1]','$fields[2]','$fields[3]','$fields[4]','$fields[5]','$fields[6]','$fields[7]','$fields[8]','$fields[9]','$fields[10]','$fields[11]','$fields[12]','$fields[13]')";

      @mysql_query($query,$server) or die(mysql_error());
}

@mysql_close() or die(mysql_error());
?>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sdmdjCommented:
Oops, change:

@mysql_close() or die(mysql_error());

to:

@mysql_close($server) or die(mysql_error());

To ensure it closes the connection we created :-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.