Ok I'm working on a project and I'm trying to dump a large amount of info into the mysql db. I'm trying with a test file first and it seems no matter how I format it, the script only reads the first set. Here is the code:
This is the source (a csv file):
No matter how I format the csv file the code stops after reading the first phone number. Any ideas on what I need to change so it actually moves on to the next set of addresses/phone numbers? Thanks in advance.
code said:<html>
<body>
<p>
<?php
include "connect.php";
if(isset($_POST['submit']))
{
$filename=$_POST['filename'];
$handle = fopen("$filename", "r");
while (($data = fgetcsv($handle, 1000000, ",")) !== FALSE)
{
$import="INSERT into RestLocation(RID, StreetAdd, City, State, zip, Phone) values('$data[0]','$data[1]','$data[2]', '$data[3]', '$data[4]', '$data[5]' )";
mysql_query($import) or die(mysql_error());
}
fclose($handle);
print "Import done";
}
else
{
print "<form action='import.php' method='post'>";
print "Type file name to import:<br>";
print "<input type='text' name='filename' size='20'><br>";
print "<input type='submit' name='submit' value='submit'></form>";
}
?>
</p>
</body>
This is the source (a csv file):
csv said:1,
2254 TIGER TOWN PARKWAY,
OPELIKA, AL, 36801,
334 -749-1255,
1,
3360 ROSS CLARK CIRCLE,
DOTHAN, AL, 36303,
334 -792-8777,
1,
401 OXFORD EXCHANGE BLVD,
OXFORD, AL, 36203,
256 -831-4911
No matter how I format the csv file the code stops after reading the first phone number. Any ideas on what I need to change so it actually moves on to the next set of addresses/phone numbers? Thanks in advance.