discussion board fopen error
I'm trying to create a discussion board, everything works fine on my computer but when I upload it to the godaddy server and try to post something, this error comes up:
Warning: fopen(messages.txt) [function.fopen]: failed to open stream
I have a txt file that stores all the data from the discussion board. I did try to create that messages.txt file on godaddy, but still get the same error.
Make sure the file has the appropriate permissions and is actually within the same directory as the script (since you haven't specified otherwise in the code).
On a side note, i'd highly (very highly) recommend moving to a database based message board system. Using a plain text file is going to get very messy very fast for all but the simplest of boards (aka something closer to a chat room). It may seem daunting at first, but using a database will, in the end, make your development a lot easier and allow the boards to scale better.
Edit: Also, is that all of the error you received? Usually the "failed to open stream" is follow by a reason of why it failed.
Last edited by Jarrod1937; 07-18-2010 at 01:43 PM.
This was the entire error. The messages.txt file is in the right place and as far as I can see, the permissions are correct. This works on my computer but not when I upload it to the godaddy server. So it's something to do with the server. I know about the databases, but I'm very new to php and want to work my way into the more complicated stuff. This discussion board is very small, mainly just for practice.
Warning: fopen(messages.txt) [function.fopen]: failed to open stream: Permission denied in D:\Hosting\3302344\html\mmwd\Board\PostMessage.php on line 54
Warning: fwrite(): supplied argument is not a valid stream resource in D:\Hosting\3302344\html\mmwd\Board\PostMessage.php on line 55
Warning: fclose(): supplied argument is not a valid stream resource in D:\Hosting\3302344\html\mmwd\Board\PostMessage.php on line 56
On your Windows PC you have your D:\ drive and folder but when you upload to the GoDaddy which maybe using Unix or Linux, D:\ cannot be understood. It is always best to work with relative path then absolute path when you play around between Windows and Unix/Linux.
Originally Posted by justbringit85
Check that the directory you are writing to has adequate permissions for the script to write to.
I guess I didn't have my godaddy permissions set right. I went and was able to allow my site to read and write. It was on inherit. Now the discussion forum works perfectly. Thank you all for helping me out with this.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread