PDA

View Full Version : PHP File -> DB field


pavmoxo
05-13-2006, 10:48 AM
I have the next code to convert php for txt:

<?php
if($_POST["phptohtml"] != "")
{
// Open a script file
$File = "http://10.0.0.9/cm-lousa.pt/2.0/newsletter/newstotxt.php";

//Open the file $File
$FileOpen = fopen($File, "r");

// Init Contain
$Contain ="";

//Create the ouptut file (temp.html as example)
touch("temphtml/news.txt");


//Open the file on "append" mode
$Add = fopen("temphtml/news.txt","a");



//Fill Contain
while (!feof($FileOpen))
{
$Contain .= fread($FileOpen, 8192);
}

//Fill temp.html
fwrite($Add,$Contain);

//Close
fclose ($FileOpen);

fclose ($Add);


}
?>


and wan't to put the content of a php file into a DB field!! How can I do this?? It's possible?

lavinpj1
05-13-2006, 11:01 AM
Yes, so long as the file is on your server...

Just fopen the php file, fread it into a variable, fclose it, connect to the database, insert it using a INSERT query.

Simple.