View Single Post
Old 06-23-2004, 07:21 AM   #4 (permalink)
jayteema
Registered User
 
Join Date: Jun 2004
Posts: 4
jayteema is on a distinguished road
I am getting a parse error now \\Can anyone see an issue

Thanks for your help

PHP Code:
<?
   
# first get a mysql connection as per the FAQ


$link mysql_connect('localhost''topselec_jt''bucket'); 

if (!
$link) { 
   die(
'Not connected : ' mysql_error()); 


// make foo the current db 
$db_selected mysql_select_db('topselec_data'$link); 
if (!
$db_selected) { 
   die (
'Can'use foo ' . mysql_error()); 





  $fcontents = file ('
./topscsv.csv'); 
  # expects the csv file to be in the same dir as this script

  for($i=0; $i<sizeof($fcontents); $i++) { 
      $line = trim($fcontents[$i]); 
      $arr = explode(",", $line); 
      #if your data is comma separated
      # instead of tab separated, 
      # change the '
t' above to ',
     
      $sql = "insert into $table values ('". 
                  implode("','", $arr) ."
)"; 
      mysql_query($sql);
      echo $sql ."
<br>n";
      if(mysql_error()) {
         echo mysql_error() ."
<br>n";
      } 
}

?>

Last edited by sde; 06-23-2004 at 10:12 AM.
jayteema is offline   Reply With Quote