Jump to content

_tina_

Members
  • Posts

    78
  • Joined

  • Last visited

    Never

Everything posted by _tina_

  1. I noticed that the csv file contains the following: name, random data, random data, random data, ,,,, How could I remove these when I import it? Thanks you in advance.
  2. Thank you for the reply. I wrote another version using fgetcsv(), but it was doing the same. Do you know what might be the cause of this?
  3. I am reading a comma delimited file into php to insert into a MySql database as follows: <? $fcontents = file ('file.csv'); for($i=0; $i<sizeof($fcontents); $i++) { $line = trim($fcontents[$i]); $arr = explode(",", $line); $sql = "insert into TABLENAME values ('". implode("','", $arr) ."')"; mysql_query($sql); echo $sql ."<br>\n"; if(mysql_error()) { echo mysql_error() ."<br>\n"; } } ?> Everything is acting as expected. The only problem is that it seems to be looping on extra time and giving me a blank set of results at the end of each line and producing the following: insert into TABLENAME values ('"name"','"random data"','"random data"','"random data",'','','','') Do you know what might be the problem? Thanks in advance
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.