Connecting Tech Pros Worldwide Help | Site Map

cannot import excell table in mysql

Familiar Sight
 
Join Date: Oct 2008
Posts: 128
#1: Jul 13 '09
cannot import table in mysql
1i saved my excell file in csv formate
2i made a data base in mysql
3i made a table with 5 fields
4i run this file


error
Parse error: syntax error, unexpected T_STRING in C:\wamp\www\test\hi.php on line 16
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. echo"hi";
  3.  $conn=mysql_connect("localhost","root","");
  4.              if(!($conn)) die("could not connect");
  5.  
  6.             $db=mysql_select_db("asdf");
  7.             if(!($db)) die("database not found");
  8. LOAD DATA INFILE 'D:\backup\institutes.csv' INTO TABLE 'inst'; 
  9. ?>
Member
 
Join Date: Jan 2009
Location: USA
Posts: 118
#2: Jul 24 '09

re: cannot import excell table in mysql


here is a link for what your trying to acomplish
http://blog.tjitjing.com/index.php/2...in-5-easy.html
Canabeez's Avatar
Member
 
Join Date: Jul 2009
Location: Israel
Posts: 85
#3: Jul 24 '09

re: cannot import excell table in mysql


Quote:

Originally Posted by kkshansid View Post

cannot import table in mysql
1i saved my excell file in csv formate
2i made a data base in mysql
3i made a table with 5 fields
4i run this file


error
Parse error: syntax error, unexpected T_STRING in C:\wamp\www\test\hi.php on line 16

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. echo"hi";
  3.  $conn=mysql_connect("localhost","root","");
  4.              if(!($conn)) die("could not connect");
  5.  
  6.             $db=mysql_select_db("asdf");
  7.             if(!($db)) die("database not found");
  8. LOAD DATA INFILE 'D:\backup\institutes.csv' INTO TABLE 'inst'; 
  9. ?>

I think you missed, mysql_query() part, and BTW this (Parse error: syntax error, unexpected T_STRING in C:\wamp\www\test\hi.php on line 16) is PHP error, not mySQL. Your code should look like:

Expand|Select|Wrap|Line Numbers
  1.             $conn=mysql_connect("localhost","root","");
  2.             if(!($conn)) die("could not connect");
  3.  
  4.             $db=mysql_select_db("asdf");
  5.             if(!($db)) die("database not found");
  6.             mysql_query("LOAD DATA INFILE 'D:\backup\institutes.csv' INTO TABLE 'inst';", $conn); 
  7.  
Reply