Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Apr 2006
    Posts
    154
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool PHP File -> DB field

    I have the next code to convert php for txt:

    PHP Code:
    <?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($FileOpen8192);
               }
               
               
    //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?

  • #2
    Regular Coder
    Join Date
    Sep 2005
    Posts
    394
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •