By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 900 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

file_put_contents problems

P: 2
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_contents 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:
Expand|Select|Wrap|Line Numbers
  1. /***************************************/
  2. $file = "ftp://USER:PASS@ftp.myftp.x10.bz/words2.txt";
  3. $lines = count(file($file));
  4. $topic = explode("\n", file_get_contents($file));
  5. $random = rand(0,$lines);
  6. $random_topic = $topic[$random];
  7.  
  8. unset($topic[$random]);
  9. file_put_contents($file, implode('', $topic), LOCK_EX);
  10.  
  11. /****************************************/
  12.  
I tried by 2 ways write some files in my host:

file_put_contents($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
Feb 17 '12 #1
Share this Question
Share on Google+
2 Replies


Dormilich
Expert Mod 5K+
P: 8,639
what is allow_url_fopen (php.ini) set to?
Feb 18 '12 #2

P: 2
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
Feb 19 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.