Cannot get php to work after installing xampp

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Cannot get php to work after installing xampp

Postby erolwi » 09. December 2006 23:31

I am about to leran php and am trying to install xampp in my pc so I can do tutorials.

But I have a problem with php. Apache seems to work fine when I chek it on http://localhost. Hen I run phpinfo() it seem fien to but hen I try to run some php code nothing is shown. Named teh ile test.php.

Didi initially not do any changes to httpd.config, php.ini. Tried adding some lines found after searching all day on the net but no success. Could not find any that helped here on teh forum either.

Ay suggestions?

Regards
Erik
erolwi
 
Posts: 6
Joined: 09. December 2006 23:08
Location: Sweden

Postby Izzy » 10. December 2006 00:02

XAMPP works just fine 'out-of-the-box' without making any changes to any conf or ini files as you have found out when you visit http://localhost.

I suggest you revert the files you changed back to the defaults, then look into your php code for errors.

If phpinfo() is working then so is php and if the XAMPP Welcome page is working and giving you the menus in the left frame then php is working as they are all .php files.

I suggest you check your php code, correct any errors, then try again.

You could always post the code here or in the German PHP forum (you can post in English if you prefer) so some knowledgable php coder can perhaps take a look at it for you.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Postby erolwi » 10. December 2006 00:14

Hi, thanks for the reply. The code was just an easy one to test.

<html>
<head>
<title>Example></title>
</head>
<body>
<?php
echo "tttttT";
?>
</body>
</html>

Should there be a page called http://localhost/mypage.php ? cus that one is not working for me either.
erolwi
 
Posts: 6
Joined: 09. December 2006 23:08
Location: Sweden

Postby Izzy » 10. December 2006 00:27

erolwi wrote:Hi, thanks for the reply. The code was just an easy one to test.

<html>
<head>
<title>Example></title>
</head>
<body>
<?php
echo "tttttT";
?>
</body>
</html>

Should there be a page called http://localhost/mypage.php ? cus that one is not working for me either.

I created a file test.php in my text editor (make sure you use a text editor like notepad, for example, to create php files) using the above code and placed in xampp\htdocs directory exactly as you posted it above.

I called it from http://localhost/test.php and it worked just fine.

I don't have a file called mypage.php. I have a stock standard XAMPP 1.55 installation with no changes at all as I use it for this very purpose of testing peoples issues.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Postby erolwi » 10. December 2006 00:54

Hi
No it do not work. If i call it test.html, nothing can be seen and if I call it test.php IE won't open it at all.

Found an error ine the file "Exalmple><

but it did not help.
erolwi
 
Posts: 6
Joined: 09. December 2006 23:08
Location: Sweden

Postby Izzy » 10. December 2006 01:11

erolwi wrote:Hi
No it do not work. If i call it test.html, nothing can be seen and if I call it test.php IE won't open it at all.

Found an error ine the file "Exalmple><

but it did not help.

The extra > won't affect anything as it is contained within the <title> tag and will just be read as another text character in html.

If you name the file test.html and it contains php code then Apache will not parse and render the php code. You must name your file with a .php extention if it contains php code.

You have to suspect your browser. Try clearing your browser's cache and set it to load a new page on every visit when testing files at the localhost. The cache is your worst enemy when testing files.

Also it pays to have more than 1 browser to test things out with. I have several browsers I can call on to test that my code is working in all popular browsers.

Also when you have tried to load the file and you get a blank window have a look at the pages source code. Right click in the window and select 'View Source'.

Here is what I see when I look at the source code:
Code: Select all
<html>
<head>
<title>Example></title>
</head>
<body>
tttttT</body>
</html>

Which means that the php code has been parsed and rendered by Apache.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Postby erolwi » 10. December 2006 20:21

Hello

Iv'e tried to reinstall xampp just to make sure that I have not done any chanes that made it wrong. I've also installed Firexox and tried it there.

Whe I run the code and look at the souce it looks like ths (called it test.html):

<html>
<head>
<title>Example></title>
</head>
<body>
<?php
echo "tttttT";
?>
</body>
</html>

when i call it text.php it wants to download the file..

e.g. the browsre does not understand the php. Also tried to run the phpinfo tile in xampp/htdocs/xampp/ with the same results...
Si is there any settings I have to do with the browsers?
erolwi
 
Posts: 6
Joined: 09. December 2006 23:08
Location: Sweden

Postby Izzy » 10. December 2006 23:52

I can't see your PC screen from here so you will have to be my eyes and try and read and understand my posts:

erolwi wrote:...souce it looks like ths (called it test.html):
Izzy wrote:If you name the file test.html and it contains php code then Apache will not parse and render the php code. You must name your file with a .php extention if it contains php code.


Tell me what you see when you type and go to:
http://localhost/xampp/index.php

When you re-installed XAMPP did you completely uninstall and delete the xampp directory first?
There seems to be a problem now with your XAMPP installation as it is not parsing php.
erolwi wrote:e.g. the browsre does not understand the php. Also tried to run the phpinfo tile in xampp/htdocs/xampp/ with the same results...
Try uninstalling completely, rebooting then reinstalling XAMPP again.

When you reinstalled XAMPP did you follow the instructions here:
http://www.apachefriends.org/en/xampp-windows.html#522
and in the readme-en.txt file.

What is the path to your XAMPP installation?
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Postby erolwi » 11. December 2006 21:49

Izzy
Thanks for being so patient with me. New to this and dont know the right words or really what to look for so hence the bad explenations. Computers just dont work as I want even sitting infornt of the all day... (Embarrasing to say that I work wit computers all day, SGI clusters, HP servers etx.)

Anyway back to my problem. I (again) installed the xampp to make sure I have not ruined any files. I installed the "Installer" version on "C:\Program". I'm running Windows XP sp2.

I installed nothing as service since it is on my laptop for script testing.

Looking in the readme_en file it seem to be written for installing without the "installer" (right?). Its only this that confuses me:

Step 4: PHP (with mod_php, as *.php, *.php3, *.php4, *.phtml), Perl by default with *.cgi, SSI with *.shtml are all located in => C:\xampp\htdocs\.
Examples:
- C:\xampp\htdocs\test.php => http://localhost/test.php
- C:\xampp\myhome\test.php => http://localhost/myhome/test.php


After this I started Apache from the XAMPP Control Panel without problem.

Logged into http://localhost and wa smet by a nice welcoming page.
Status page shows everything works fine, all activated apart from SMTP and FTP services.

phpinfo() also diplays a nice side with lots of info I cant really comment on.

The Demos works fine too.
The phpMyAdmin works like a charm too (at least displaying the side)

Then I run into trouble.
Created a file like above, naming it test.php. Looking at teh file in the explorer it has a funny IE Icon (like a white rectangular with a badly resolved small "e" (I'm using IE7 but I also have Firefox installed). When I open the file (by double-clicking) its takes a while but then I get a "file download" window asking me to save or open teh file, and opening does not work. The file was located in "My documents" but I read somewhere to put the files in /xampp/htdocs/ but that dont work either...

Naming the file test.xtml teh file shows nothing when open in IE but the source code shows the whole souce code including the php parts.

So I hope this explains it better. I'm sure I've forgotten/missed something (like Step 4 above) but cannot figure out what. Read as much I could about installing php on apache and everyhere they say I must add lines in the /apache/conf/httpd.config file, like such:

LoadModule php5_module "D:/Programming Apps/PHP/php5apache2.dll"
AddModule mod_php5.c
AddType application/x-httpd-php .php


And then copy the php.ini file to different directories (either the recommended or the other) and possibly do chanes to that one too...

Have not done any of this now and it is "like new", so do you (or anyone else have any suggestions (apart from buying a new computer)?

/Erik
erolwi
 
Posts: 6
Joined: 09. December 2006 23:08
Location: Sweden

Same problem

Postby jbh185 » 11. December 2006 23:43

I have just installed XAMPP(automatic installer) and files with php do not work properly. I tried to open infophp(in the xampp/htdocs/xammp folder) and the browser does not show anything in the page(IE or Mozilla). I create html documents in htdocs and they work fine, but when I add <? phpinfo(); ?> or other php code the browser shows only the html already in the file.

Thanks for any help.
jbh185
 
Posts: 1
Joined: 11. December 2006 20:13

Postby Izzy » 12. December 2006 01:05

Here is the problem.
erolwi wrote:Then I run into trouble.
Created a file like above, naming it test.php. Looking at teh file in the explorer it has a funny IE Icon (like a white rectangular with a badly resolved small "e" (I'm using IE7 but I also have Firefox installed). When I open the file (by double-clicking) its takes a while but then I get a "file download" window asking me to save or open teh file, and opening does not work. The file was located in "My documents" but I read somewhere to put the files in /xampp/htdocs/ but that dont work either...

Here is the solution.
You can't open a php file in your browser by double clicking on it in a directory if it contains php code that the server needs to parse and render for you to view it.

You must go through your server by typing an address first.

Put your created test.php in xampp\htdocs\ directory and then call it in your browser when you have started your XAMPP servers.
http://localhost/test.php

If it's in the xampp\htdocs\xampp\ directory you call it in your browser by using this address:
http://localhost/xampp/test.php

If you create a directory called myhome in xampp\htdocs and you put your test.php file in there then you call it like this:
http://localhost/myhome/test.php

localhost/ = xampp\htdocs\
localhost/myhome/ = xampp\htdocs\myhome\
localhost/xampp/myhome/ = xampp\htdocs\xampp\myhome\

Get the idea?

Each directory that you call with just a slash should have an index file like index.php or index.html or index.htm etc. or you use a specific file in the address bar like above with the test.php file.

http://localhost/ = http://localhost/index.php = \xampp\htdocs\index.php
http://localhost/myhome/ = http://localhost/myhome/index.html = \xampp\htdocs\myhome\index.html
http://localhost/xampp/myhome/ = http://localhost/xampp/myhome/index.htm = \xampp\htdocs\xampp\myhome\index.htm

If this is not clear then let me know.

Double clicking on a file just won't work it must be called by an address in your browser and go through your server so the server can parse the php code and present it to your browser as intended.

jbh185 wrote:I tried to open infophp(in the xampp/htdocs/xammp folder) and the browser does not show anything in the page(IE or Mozilla).

The same applies to you. Call the file by using an address not by double clicking as you would if using your file manager - Windows Explorer.

I have both .php and .htm .html files associated with my text editor so if I double click on them, my text editor (notepad) will open the files for editing not my browser.
Izzy
 
Posts: 3344
Joined: 25. April 2006 17:06

Thanks

Postby erolwi » 12. December 2006 20:57

Thanks a lot!
Now it works and I also belive I understand how it works with the local host.
Now I only have to learn php and MySql to get my website up and running.

I signend the whales revenge as a thank!
Have a nice day
Regards
Erik
erolwi
 
Posts: 6
Joined: 09. December 2006 23:08
Location: Sweden


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 69 guests