View Full Version : Read If You are Having Trouble Getting PHP To Work
NathanRX7
1-4-02, 03:01 AM
I am seeing a lot of threads on here about people getting general errors trying to run PHP scripts. Assuming your PHP code is written correctly, all you have to do to make it work is:
1. Put #!/usr/local/bin/php at the top of each PHP file that will be accessed directly from a Web browser.
2. Upload all of your PHP files in ASCII mode. There is an option to do this right at the bottom of the WS_FTP LE window. If you're using a different FTP client, you're on your own to find ASCII mode.
3. CHMOD 755 the directory that contains your PHP files, and all of your PHP files. Again, in WS_FTP LE, all you have to do is select the file(s) you want to CHMOD, right-click them, and select chmod (UNIX). In the window that pops up, select Read, Write, Execute under Owner, and select Read, Execute under Group and Other. This will set the permissions to 755.
If you do all this, and your PHP still doesn't work, it is most likely that there is an error in your code. Good luck.
Thanks for the info. It is good that have this laid-out in a straight-forward post.
However,
I do not have to take these steps on my site (which is on the saturn server). I simply give the file a .php extention & upload. I have suggested some .htaccess directives that are being tested on the other servers... we'll see if they work.
Peace,
- Earl
Earl,
We just haven’t converted your web server over to the cgi method of PHP yet.
jbenalluch
1-4-02, 08:59 AM
starr, i find very problematic having to add everytime the top line #!/usr/local/bin/php on each of my php files, as i have a bunch of them.
I have read around the boards that it was possible to add directives to the .htaccess file to avoid doing so.
For those who are already on a php/cgi mod, what would be the directive to add in the .htaccess files for us to avoid to have to put the top lines in each file?
If that is possible, then i think it would be very useful publishing it in the FAQs, which would avoid the endless trouble to get the most scripts working (i spent two days before i could get this script to work:
<?php
echo "this is a test to see if it is working";
?>
)
I think it would also be interesting to post in the FAQs the fact that you have to upload your php files in ASCII mode.
Thanks for your attention
NathanRX7
1-6-02, 04:14 AM
Yes the .htaccess thing would be nice, but I have found another solution so that I don't have to add the directive to the top of every page. Look at http://www.goldcoastinspections.com/. You can see that every page you go to is index.php but I pass a variable through the links called page, and it requests a certain page to be included. In my index.php, I have an if statement that looks to see what page is being called, and it includes it in the template for the site. This is also very convenient because I can make changes to the frame of the site, and I only have to do it in 1 page, index.php.
Doing it this way, only index.php needs to have the directive, because all of my other PHP files are being included rather than being called by the Web browser. Hope this helps.
By the way, it is in the FAQ that you have to upload in ASCII mode.
Another thing to note is that you cannot have Carriage Returns in your code, only Line Feeds.
This is important if, say, you are using a WYSIWYG editor such as Dreamweaver or FrontPage.
In Dreamweaver, you can eliminate Carriage Returns by checking the Code Format page in the Preferences window.
DigitalGhost
1-13-02, 07:56 AM
Why convert to the most resource intensive version of PHP rather than simply using Apache module?
DigitalGhost
vBulletin v3.6.0, Copyright ©2000-2009, Jelsoft Enterprises Ltd.