cannot import excell table in mysql

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kkshansid
    New Member
    • Oct 2008
    • 232

    #1

    cannot import excell table in mysql

    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\tes t\hi.php on line 16
    Code:
    <?php
    echo"hi";
     $conn=mysql_connect("localhost","root","");
                 if(!($conn)) die("could not connect");
    
                $db=mysql_select_db("asdf");
                if(!($db)) die("database not found");
    LOAD DATA INFILE 'D:\backup\institutes.csv' INTO TABLE 'inst'; 
    ?>
  • wizardry
    New Member
    • Jan 2009
    • 201

    #2
    here is a link for what your trying to acomplish

    Comment

    • Canabeez
      New Member
      • Jul 2009
      • 126

      #3
      Originally posted by kkshansid
      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\tes t\hi.php on line 16
      Code:
      <?php
      echo"hi";
       $conn=mysql_connect("localhost","root","");
                   if(!($conn)) die("could not connect");
      
                  $db=mysql_select_db("asdf");
                  if(!($db)) die("database not found");
      LOAD DATA INFILE 'D:\backup\institutes.csv' INTO TABLE 'inst'; 
      ?>
      I think you missed, mysql_query() part, and BTW this (Parse error: syntax error, unexpected T_STRING in C:\wamp\www\tes t\hi.php on line 16) is PHP error, not mySQL. Your code should look like:

      [code=php]
      $conn=mysql_con nect("localhost ","root","" );
      if(!($conn)) die("could not connect");

      $db=mysql_selec t_db("asdf");
      if(!($db)) die("database not found");
      mysql_query("LO AD DATA INFILE 'D:\backup\inst itutes.csv' INTO TABLE 'inst';", $conn);
      [/code]

      Comment

      Working...