Problem with reading a file and inserting into table[Solved]

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
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Problem with reading a file and inserting into table[Solved]

Post by infolock »

hello again :) first, i want to thank everyone who has helped me through my learning process. lots of help has been provided and it's all done wonders. however, i have a new problem...

currently, my script is reading a file, and when it gets to line 4, it parses the data and assigns it to an array. i'm trying to dump that array into a table, but i'm having problems. here is the call

Code: Select all

<?php
    elseif ($line_no > 4) 
    { 
     // Read column and update.
                 $info_data = preg_split("/[\s]+/", $line_data);
                 $qry="insert into TABLE loginfo values('".$info_data[0]."','".$info_data[1]."')";
                 mysql_query($qry) or die(mysql_error());
     }

?>
however, when i run this, it gives me this error message :
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'TABLE loginfo values('213.111.11.14','2003-10-18')' at line 1
i've tried sitting it outside of the loop, but it has the same result ( except it only reads the last value that the array is assigned but still generates the same error).

any help would be appreciated. 8O
Last edited by infolock on Thu Nov 06, 2003 7:14 pm, edited 1 time in total.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

Code: Select all

insert into loginfo...
Notice that you can't use TABLE keyword in this context.

read this fine ;) manual...
Last edited by Weirdan on Thu Nov 06, 2003 3:34 pm, edited 1 time in total.
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

thanks :oops:
Post Reply