hai friends Iam having a file named as demo.txt , now i want to insert this file in the mysql database and then i want to retrieve the content of the demo file and i want to display it in the browser can any body GIVE THE PHP CODE FOR THIS THANK U IN ADVANCE
//let $abc be the variable to store data from the file and function file_get_contents is used to extract data in file $abc = file_get_contents("demo.txt"); //then your mysql query, let content be the table and demo the field mysql_query("UPDATE content SET demo='$abc' where id='$id'") or die(mysql_error()); //here's the fetching part doing it the mysql_fetch_array method $sql = mysql_query("SELECT * FROM content WHERE id='$id'"); $row=mysql_fetch_array($sql); $anything=$row['fieldname']; //demo now stores the data of $abc that was stored earlier $demo=$row['demo'] PHP:
I can't really see any need for a database here - all you would really need to do, to display the contents of a specific file in the browser window, is use the following code (place demo.txt in a directory named "text_files" in the directory of the php script for this to work...) readfile("text_files/demo.txt"); PHP: Easy as (although if you do actually need to have the contents in the database too, the code posted before mine would work just fine!)