right forum for phpmyadmin advice?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
bufhal
Forum Newbie
Posts: 19
Joined: Sat Apr 17, 2004 11:39 am

right forum for phpmyadmin advice?

Post by bufhal »

Hello;
I have saved an Excel file with same fields as MySQL database with a "," at the end of each record(row) and nothing at end of each field. I saved as CSV (not Mac or Dos). Tried to upload to phpmyadmin but get the following error everytime. Do I have the wrong version? MySQL 4.0.14-nt
If I do, what can I do to easily upload these text files?
Thank you :roll:

Error
SQL-query :
LOAD DATA LOCAL INFILE 'C:\\Backup\\dot\\uploadtemp\\php673.tmp' INTO TABLE `agencies` FIELDS TERMINATED BY ','
MySQL said:
#1148 - The used command is not allowed with this MySQL version
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Can use something like this:

Code: Select all

<?php
   include("database.php");	#connect to database and stuff
   #checks that file was uploaded
   $uploadfile = 'data.txt';
   if(!move_uploaded_file($_FILES['upload']['tmp_name'], $uploadfile)){
      echo "unable to upload the file";
   }else{
      $fp = fopen($uploadfile, 'r');
      while(!feof($fp)){
         $data = fgets($fp, 1024);
         if($data){
            $data = explode(",", $data);
            for($x=0; $x<count($data);$x++){
               $data[$x] = str_replace('"', '', $data[$x]);
            }          

            mysql_query("INSERT INTO stats VALUES ('$data[0], '$data[1]', '$data[2]', '$data[3]', '".trim($data[4])."', '$data[5]', '$data[6]', '$data[7]', '$data[8]', '$data[9]', '$data[10]', '$data[11]', '$data[12]', '$data[13]', '$data[14]', '$data[15]', '$data[16]', '$data[17]', '$data[18]')");
         }
      }
      fclose($fp);
      unlink($uploadfile);
   }
?>

<center>
   <h2>Successfully Added File</h2>
</center>
bufhal
Forum Newbie
Posts: 19
Joined: Sat Apr 17, 2004 11:39 am

thanks for the responce

Post by bufhal »

Kettle_drum
Can I post the PHP portion of my index.php page, or is that where your code would go? Are you familiar with that error-what causes it?
Thanks..
bufhal
Post Reply