file_put_contents problems

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Carlos Maya
    New Member
    • Feb 2012
    • 2

    file_put_contents problems

    Hi, I am very new in this language and I have some problems and I can`t handle it.

    Maybe somebody can help me?
    file_put_conten ts and fopen does not work for my and I don´t know what happen :S


    Abstract:
    1. I need read a random line in a txt hosted in a FTP
    2. I need delete this randome line from that txt
    3. Next I need put the extracted random line in another txt (not coded yet)


    Here is my code:
    Code:
    /***************************************/
    $file = "ftp://USER:PASS@ftp.myftp.x10.bz/words2.txt";
    $lines = count(file($file));
    $topic = explode("\n", file_get_contents($file));
    $random = rand(0,$lines);
    $random_topic = $topic[$random];
    
    unset($topic[$random]);
    file_put_contents($file, implode('', $topic), LOCK_EX);
    
    /****************************************/
    I tried by 2 ways write some files in my host:

    file_put_conten ts($file, "sometext", FILE_APPEND);

    AND

    $fh = fopen("$file", "w");
    fwrite($fh, "sometext") ;
    fclose($fh);

    But those does not work. I put this file 0777 permitions and does not work :S

    Someone knows what happening?

    PHPversion: 5
    Host: http://www.x10hosting.com/

    Thanks in advance.

    Regards
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    what is allow_url_fopen (php.ini) set to?

    Comment

    • Carlos Maya
      New Member
      • Feb 2012
      • 2

      #3
      Thanks for your try, I solved it moving all my data to noFTP system, I think that my server block in any way the FTP connections.

      Regards

      Comment

      Working...