Can't get php to work

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Liansky
Forum Newbie
Posts: 15
Joined: Thu Jun 19, 2003 12:56 pm

Can't get php to work

Post by Liansky »

HI there. I'm new to both this forum and proggramming php.

I downloaded the latest php(4.3.2) and manually installed it, and then i installed the latest Apache(2.0.46) via the installer.
The problem is, i inserted the "hello world" example into the apache folder, and all i get is the heading and nothing else. Hello world does not appear on the web page. The echo function does not seem to work.

An example of the "hello world" example....
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo "<p>Hello World</p>"; ?>
</body>
</html>


I can get it to work using a html extension, but only gives me the heading when using the php extension.

Here's a list of things i did....
copied c:\\php\php4ts.dll to c:\\winnt\system32
copied c:\\php\php.ini-reccomended to c:\\winnt and renamed it to php.ini
set doc root in php.ini file to point to apache
added code to the apache config file to configure php and apache as module
changed extension_dir(in php.ini) to be eqaul to c:/php/extensions
changed :extension = php_bz2.dll and took away the ';'

What else should i do to make the thing to work.

I use win2000 by the way...
User avatar
cactus
Forum Regular
Posts: 343
Joined: Tue Jun 10, 2003 4:16 am
Location: UK

Post by cactus »

The problem could be due to the miss-association of .php extension in your apache config.

When you ran the script did it show everything you dipslayed above, including the "<?php echo "<p>Hello World</p>"; ?>" and not just "Hello World" ?

The following references should point you in the right direction:

http://uk.php.net/manual/en/install.windows.php
http://uk.php.net/manual/en/install.apa ... he.windows
http://httpd.apache.org/docs/windows.html

Regards,
Liansky
Forum Newbie
Posts: 15
Joined: Thu Jun 19, 2003 12:56 pm

Post by Liansky »

Thank you oh so much for giving me the links. I'll try them now...

When i ran the script, it only showed the heading(PHP Test), and a blank page...
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

What did the source code of the page look like?

Mac
Liansky
Forum Newbie
Posts: 15
Joined: Thu Jun 19, 2003 12:56 pm

Post by Liansky »

Source code?? You have to more specific on that one...
Liansky
Forum Newbie
Posts: 15
Joined: Thu Jun 19, 2003 12:56 pm

Post by Liansky »

To be more specific, the echo doesn't work....
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

Did you try a "view/show source" on the page?
Liansky
Forum Newbie
Posts: 15
Joined: Thu Jun 19, 2003 12:56 pm

Post by Liansky »

Um, i have no idea what that is. I'm shamefully new at this.

Maybe i'll just delete everything, and start all over again...
User avatar
releasedj
Forum Contributor
Posts: 105
Joined: Tue Jun 17, 2003 6:35 am

Post by releasedj »

Take a look at the PHP manual for setting up Apache 2 http://www.php.net/manual/en/install.apache2.php.

This will give you some guidelines into setting up the server for php.
Liansky
Forum Newbie
Posts: 15
Joined: Thu Jun 19, 2003 12:56 pm

Post by Liansky »

I did, and i cannot figure out where i went wrong. I even made notes on every single change that i made.

But, i'm re-installing my operating system, so i'll try to do it over. My pc started going all bonkers after i tried to install Enter The Matrix.... which didn't install right. How typical....
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

nielsene wrote:Did you try a "view/show source" on the page?
Liansky wrote:Um, i have no idea what that is....
Ok after you finish the re-installing you mention, try this:
1) Try loading your hello world example, make sure the hello world file has a .php extension, not a .html
2) If the "hello world" doesn't show up, go to the menu bar of your browser, select "View" and then select "Source" (in MSIE) or "Page Source" (in Mozilla/Netscape)

3) Is the <?php echo ... ?> line visible in the source window that opens?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

if you use the php zip package from http://php.net/downloads you can do the installation by the book (aka install.txt). But note the ATTENTION: Apache 2 Users section.

you might test the php installation stand-alone first.
Create a small script file in your php directory, e.g. called test.php containing something like <?php phpinfo(); ?>
now open a command shell, change to your php directory and type php.exe -l test.php
If php itself works properly it should return No syntax errors detected in test.php
Now you can move the script file to the htdocs directory of your apache.
if you request http://localhost/test.php now and see nothing, open the source view. If the complete script is shown your Apache isn't set up to let php handle php-scripts and you have to check Installing PHP for Apache as module in install.txt again (if you're going to install php as module. Installing PHP for Apache as CGI binary if you plan to run php as cgi)
User avatar
releasedj
Forum Contributor
Posts: 105
Joined: Tue Jun 17, 2003 6:35 am

Post by releasedj »

Maybe it's worth getting a package which installs PHP, MySQl and Apache together to start with.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

yo, I'm always too focused on the initial question.
phptriad has been mentioned here some times.
wampp is another package
wampp 2.2
ZIP RAR 06. june 2003
42 MB 33 MB released
apache 2.0.46, MySQL 4.0.13, PHP 4.3.2 + PEAR, Perl 5.8.0, mod_php 4.3.2, mod_perl 1.99_10, mod_ssl 2.0.46, openssl 0.9.7b, PHPMyAdmin 2.5.1, Webalizer 2.01-10, Mercury Mail Transport System for Win32 and NetWare Systems v3.32, JpGraph 1.12.1, Fastsream NetFile Server 5.6.0.511, (WEB-DAV + MOD AUTH MYSQL experimental); well suitably as server service under NT, w2k, XP Prof. [last modify: 06.06.02]
Liansky
Forum Newbie
Posts: 15
Joined: Thu Jun 19, 2003 12:56 pm

Post by Liansky »

Volka, you are a <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> genius without even knowing it for Christs sakes. All i had to do was move my file to htdocs. I mean <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>, i thought i had to leave it in the main apache folder. Thank you very much and God <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span> bless...

To all of the others: You see, i know how to read a goddamn manual. Just a pity the goddamn manual aint specific on where to move the source code...
Post Reply