Page 1 of 1

How can I........

Posted: Wed Aug 21, 2002 10:10 pm
by Razael
I was wondering if when someone submits a txt file and the contents of the text file can be inserted in a mysql table acording to the name of the textfile. and then reading the information that was inserted in the MySQL database, and then using the include form, the information is inserted into a HTML page. Can this be possible?!?

Posted: Thu Aug 22, 2002 1:18 am
by Takuma
Don't know about the file name of text but you can insert the txt file's content in to MySQL:-

Code: Select all

<?php
//INSERT DATA INTO TABLE CALLED "txt" which has 2 fields (one is ID auto_incremented).

  $sql = "INSERT INTO txt VALUES(NULL,"&#123;$_POST&#1111;'TEXTFILE']&#125;")";
  $temp = mysql_query($sql);

//READ DATA
  $sql = "SELECT id FROM txt WHERE id = 'ID NUMBER'";
  $temp = mysql_query($sql);
  list($result) = mysql_fetch_array($temp);
   echo $result;
?>
This should work although I haven't tested it. :arrow:

Posted: Thu Aug 22, 2002 4:53 am
by mikeq
When inserting into a table with an auto-increment do it like this



$sql = "INSERT INTO txt (textcontent) values ('$ValueToBeInserted')";

txt (textcontent) this part specifies all of the fields you want to insert into seperated by commas, you must do this if you are not inserting into all fields. Do not include the auto-increment field and do not try to pass NULL, as Takumas insert query would do.

Posted: Thu Aug 22, 2002 4:32 pm
by Razael
Thanks a lot guys!