473,386 Members | 1,644 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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_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
2 2252
Dormilich
8,658 Expert Mod 8TB
what is allow_url_fopen (php.ini) set to?
Feb 18 '12 #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

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

Similar topics

4
by: Michael Preminger | last post by:
Hello! We are running php 4.3.10 Therefore I need to use php_put_contents through pear. Thats what my file looks like: <?php require_once 'php/Compat/Function/file_put_contents.php';
14
by: Jim Hubbard | last post by:
Are you up to speed on the difficulties in using the 1.1 .Net framework? Not if you are unaware of the 1,596 issues listed at KBAlertz (http://www.kbalertz.com/technology_3.aspx). If you are...
1
by: 3f | last post by:
Hello; We have made a web application that people can download from our web site and installed on: Windows XP Windows 2000 Professional Windows 2003 Server Windows 2000 Server
5
by: Corky | last post by:
This works: db2 SELECT DISTINCT PROBLEM_OBJECTS.PROBLEM_ID FROM PROBLEM_OBJECTS INNER JOIN PROBLEMS ON PROBLEM_OBJECTS.PROBLEM_ID = PROBLEMS.PROBLEM_ID WHERE INTEGER(DAYS(CURRENT DATE) -...
10
by: BBFrost | last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net 2003. At first things were looking ok, now problems are starting to appear. So far ... (1) ...
7
by: amygdala | last post by:
Hi, I'm trying to let PHP write a 'sitemap.xml' sitemap for Google and other searchengines. It's working, except that the content in the XML file doesn't seem to be UTF8. (Which it should be,...
4
by: cookspyder | last post by:
I have a PHP file that when i run the code on my test server(wamp) writes everything in one stream in the file. On win 2003 server IIS I get strange hard returns and spacing between some of the...
9
moishy
by: moishy | last post by:
When I try to write to file like this: file_put_contents("test.txt","Hello World"); I get an error: Fatal error: Call to undefined function: file_put_contents() File_get_contents works...
5
by: ^AndreA^ | last post by:
Hello everybody, I'm trying to get a file on the internet and put it on my server... So, from javascript (AJAX) a call a php function that is simply: file_put_contents('RSS_news/bbc.xml',...
3
by: luttkens | last post by:
All of a sudden I have discovered that it is no longer possible to create files on my server by running php scripts. When I call the function file_put_contents() it returns false. It worked...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.