473,396 Members | 1,866 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,396 software developers and data experts.

Error with file_put_contents()

moishy
104 100+
When I try to write to file like this:
[PHP]file_put_contents("test.txt","Hello World");[/PHP]
I get an error: Fatal error: Call to undefined function: file_put_contents()

File_get_contents works perfectly, I can't figure out why I can't write!
Any help?
Nov 14 '07 #1
9 37458
Atli
5,058 Expert 4TB
Hi.

Are you absolutely sure there isn't a typo in the function name?

You could always try going the long way around:
Expand|Select|Wrap|Line Numbers
  1. $fh = fopen("file.txt", "wb");
  2. fwrite($fh, "some text");
  3. fclose($fh);
  4.  
Nov 14 '07 #2
moishy
104 100+
I am placing the entire contents of my php file:
[PHP]<?php
echo file_put_contents("test.txt","Hello World. Testing!");
?>[/PHP]
Instead of returning 21 it returns Fatal error: Call to undefined function: file_put_contents() in...
Nov 14 '07 #3
pbmods
5,821 Expert 4TB
Heya, Moishy.

file_get_contents() was introduced in PHP 4, but file_put_contents() is only available in PHP 5. What version are you running?
Nov 14 '07 #4
moishy
104 100+
I'm not sure what version I have.
I am hosted by godaddy.com
Nov 14 '07 #5
Atli
5,058 Expert 4TB
You could use the phpinfo() function to find out which version you have.

Just create a new .php file, add the following and navigate to it in a browser. It will bring up every detail on your PHP configuration.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.   phpinfo();
  3. ?>
  4.  
Nov 14 '07 #6
pbmods
5,821 Expert 4TB
Heya, Moishy.

Have a look at this article.
Nov 15 '07 #7
moishy
104 100+
Heya, Moishy.

Have a look at this article.
Thanks a lot! You were very helpful!
Nov 16 '07 #8
pbmods
5,821 Expert 4TB
Heya, Moishy.

We aim to please.

Good luck with your project, and if you ever need anything, post back anytime :)
Nov 17 '07 #9
I know this is an old post but I just wanted to clear this up. GoDaddy doesn't offer file_put_contents() for PHP5 hosting. I had to use fwrite(). Thanks Atli.
Jul 21 '12 #10

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

Similar topics

2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
5
by: Tony Wright | last post by:
Hi, I am having a problem installing an msi for a web site. The error message I am getting is: "The specified path 'http://mipdev05/features/Fas2' is unavailable. The Internet Information...
1
by: Aravind | last post by:
we have two files: 1. rc4.c (defines one function "create_pin()") 2. MyImpl.c(calling the function "create_pin()"),This implements JNI method. 1.When I am trying to create .dll file with one...
13
by: deko | last post by:
I use this convention frequently: Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case 3163 Resume Next Case 3376 Resume Next
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
5
by: yashu0209 | last post by:
I have an error occurring when i try to compile the program and the error is: D:\Program Files\visual studio 6.0\MSDev98\MyProjects\GLEnabledView\GLNew.cpp(164) : error C2653: 'CGLEnabledView' :...
2
by: randa zaghdan | last post by:
Hi I have a problem with my program in vc 2008 When I compile it, the following errors are listed. I try to resolve it but no hope Does any one can help me ? thanks . Linking......
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: 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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.