Join 132,671 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,182 people online right now. Registration is fast and FREE... Join Now!
I am working my way through a text-book ... "PHP and MySql Web Development" by Luke Welling and Laura Thompson, 3rd edition. I have done these exercises in class as well. I am now at home trying to figure out how to make it work on my own pc!
I am in chapter 2, working through reading and writing to files. I am using a windows system (inetpub/wwwroot directory) and have downloaded and installed php 5 and mysql 5, both are working and am using dreamweaver 8 as an editor. The problem I am having is that when I specify a file to save text to I get the message "unable to process order at this time" which is the message I coded to be shown if the file does not open. Now I have created the txt file manually, and tried all sorts of ways to append/write to that file.
The filepath and its location on my computer is: C:\inetpub\wwwroot\myphpandmysqlsite\orders\orders.txt
I have tried assigning the path in the code to a variable and then passing that variable to the fopen() function and still no joy.
I am wondering if it is possible that I haven't updated my php.ini file enough???
I apologise if there is a topic that has already covered this but I put some keywords through the search engines with no luck...
Please let me know if you need to see what I currently have coded..
It sounds like everything's in order. If you don't mind posting the file-write portion of your code, that might help. Not sure if I can solve your problem, but I'm happy to take a look at it.
Is your code identical to what you did in class? If not, have you tried this same file on another server?
Is your code identical to what you did in class? If not, have you tried this same file on another server?
No ... the one we did in class we had to alter as well because we had problems with the $DOCUMENT_ROOT. I have initially tried the book's code (verbatim), then in desperation tried the code from school, then tried to fix it by tweaking it here and there after looking at online tutorials etc. The latest version assigns the full path and file name (yes the file already exists) to a variable ... see below.
CODE
$outputstring = 'this is a test to see if I have any output';
echo '<p>My output string is '.$outputstring.'</p>';
It should tell you the file permissions on that file. Anything 0666 and above is generally good just for testing.
If you want to try changing the permissions, look up how to use chmod
do the permissions for the entire folder need to be both read and write or just the text file itself... am thinking this is my problem because I have already tried the following relative addresses.. where I have specified ...
I am thinking that it is probably a permissions issue, and have gone into the iis administrator and changed the text file to accept read and write but still no joy... maybe the entire folder must be changed?
other than that, in your php.ini, you can try looking for disable_functions and see if anything's listed
my php.ini looks like this...
QUOTE
; This directive allows you to disable certain functions for security reasons. ; It receives a comma-delimited list of function names. This directive is ; *NOT* affected by whether Safe Mode is turned On or Off. disable_functions =
in the directory you are adding / deleting / modifying files, make sure that the "Internet Guest Account" has access rights to do all of the above. Do this by right clicking on the folder in question, selecting properties. now click the security tab. IUSR_<computer name> is probably not in there, so click "add user..."
now, click advanced and do a search. pick the internet guest account from that list, click ok. now specify the permissions you want that user to have.
if you do in fact already have IUSR_<computer name> in there with all permissions and am still getting this problem, then we have another problem on our hands
Is it possible that your php document root is unaware of the full path? Try using %DOCUMENTROOT/pathtofile rather than C:\fullpath\pathtofile, because using C:\ is going outside of where %DOCUMENTROOT boundry. Can you code find/read the file, or is it only writting to it that has the problem?
in the directory you are adding / deleting / modifying files, make sure that the "Internet Guest Account" has access rights to do all of the above. Do this by right clicking on the folder in question, selecting properties. now click the security tab. IUSR_<computer name> is probably not in there, so click "add user..."
now, click advanced and do a search. pick the internet guest account from that list, click ok. now specify the permissions you want that user to have.
if you do in fact already have IUSR_<computer name> in there with all permissions and am still getting this problem, then we have another problem on our hands
Okay I'm getting a little bit lost now... just a little bit. I do have an IUSR_(my computers name) account and I checked this out by going into the iis administration and right clicking on the website's properties. Under the directory security tab I clicked the Edit button in the top area (enable an anonymous access). The IUSR_(my computers name) is in there with iis controlling the password check-box selected. I do not seem to have an advanced button there that allows me to select the users permissions... am I in the right place?
Now when I am in the above area there is a browse button to help you find the names you can select. Inside that there is an advanced button, however window that opens from that does not have any permissions areas either?? So you can see I am a little lost and this is perhaps because I am looking in the wrong place?
To check the permissions, actually browse the folder in Windows Explorer, right click on it, and select properties. Go to the Security tab. In that list you will see the Internet Guest Account. Make sure that user has write privileges on your folder.