PDA

View Full Version : Any one know anything about php?



bornl33t
03-27-2004, 06:10 PM
Well to make a long story short, I gotta do it for school and I can't even get <?php echo '<p>fart</p>';?> to work on either redhat 9 (mozilla) or windowsXP (IE6). mozilla drops to html after the </p> part and windows doesn't recognize any php. I understand the code I just don't know how to implment it. Do these browsers not understand php? I mean it IS a server side language, so maybe I need a php server to translate it for the browser?
I don't know I'm stumped right now.

HEEEEELLLLLPPPPP

Dryden
03-27-2004, 06:49 PM
PHP is a server-side scripting language, everything should be processed through a PHP-aware web server, like Apache, and passed as plain HTML to the browser. That's the beauty of PHP, it's transparent to the end user, so they can't rip-off your code like they can with JavaScript, VBScript, etc.

Open an editor and copy this into a text file:

&lt;?php

phpinfo();
phpinfo(INFO_MODULES);

?&gt;

This is it for the code - no HTML. Save the file as info.php and place in a directory accessible on the web server. If PHP works, you should get a list of hundreds of environment variables. If not, you'll need administrative access to the server to begin stepping through Apache setup.

bornl33t
03-28-2004, 06:29 PM
I understand all that, when I view it through the browser though I cannot get it to return html...so I'm assuming my php server isn't running or something.

I'm doing this with RH 9.... does it not have a built in php server?

Dryden
03-28-2004, 07:44 PM
Open a console window with root access, then try:

rpm -q php

to see which version you have installed (if any). You could also try invoking the php engine directly at a command prompt with:

php -v

to check which version of apache is installed, try:

rpm -q httpd

RH 9 should respond with php-4.2.2 and httpd-2.0.40 or close to that.

You may need to edit /etc/php.ini to enable the engine. Around line 68 should be a line set to:

; Enable the PHP scripting language engine under Apache.
engine = On

Next, check /etc/httpd/conf.d for a file named php.conf. Contents should be:

LoadModule php4_module modules/libphp4.so

&lt;Files *.php&gt;
SetOutputFilter PHP
SetInputFilter PHP
LimitRequestBody 524288
&lt;/Files&gt;

DirectoryIndex index.php

There shouldn't be a php server per se, rather Apache has to know that php is there and to pass files that have a .php extension to the php engine. The php.conf in /etc/httpd/conf.d handles this function. If you make any edits, make sure you restart Apache with a:

service httpd restart

Good luck!

bornl33t
03-28-2004, 09:06 PM
ok, check all the above and everything is good.
but mozilla still will not read php

Do I need to store php files in a certain directory?

Dryden
03-28-2004, 09:38 PM
Your PHP files need to be in a directory that your web server hosts pages from, usually /var/www/html on RH9.

In my first post, take that code snippet and save into a file named info.php

Then, from the console, in the directory where the info.php file is stored, run:

php -q -f info.php

This will dump html to the console. If that works, try placing the info.php script into /var/www/html, then open a web browser and visit

http://localhost/info.php

bornl33t
03-29-2004, 06:07 AM
well it dumped a couple dozen pages of info, so that was good, then Opened mozilla and tried to run the code and I got raw php returned again. I just don't get it.
I mean I understand and at this point could pry already have made significant progress with this assignment, but my freaking puter is boycotting php. I'm about to boot up windows and install the php server from php.net and say screw rh. I mean I like rh and all, but I jsut haven't played around enough to seriously know what I'm doing in rh.

thanks for your help, I think I just need to talk with my teacher and ask him, I'm sure he can help me, I just wanted to be able to have something to show him before saying I don't understand this. I'll pry write up a few pages then ask him why I can't run it and then debug it later during class or something.

Oh yeah and hte sql in your sig is killer :D

Thanks again, if ya got any more ideas I'm willing to listen, but I wouldn't hold it against ya if rather invest your time with something more rewarding then this....

Heat out

Dryden
03-29-2004, 09:31 AM
Are you on cable or dsl? Public IP? I'd be more than happy to telnet or ssh into your server and take a look for you.

PM me if interested. It'd be a quick setup. I've been doing this stuff at an ISP since '95.

bornl33t
03-29-2004, 01:23 PM
umm... sure I don't see why not. I'm on a cable line. What do I need to setup for you to get going?