What's the problem?

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

s2009
Forum Newbie
Posts: 20
Joined: Thu Apr 30, 2009 1:20 am

What's the problem?

Post by s2009 »

Hi all

I am beginner learning Php.
I have installed Php Designer 2008. I have written first program in Php as follows :

Code: Select all

 
<html>
<head>
<title>Untitled 2</title>
</head>
<body>
<?php
echo "HELLO WORLD"
?>
</body>
</html>
 
I have saved the above file with .php extension. But when I try to open the file in InternetExplorer it is opening the file in DreamWeaver. And if I try to open it in FireFox Mozilla it is just displaying blank page.

Can anyone help me to get the desired output.?

Please help me out.

Thanks in advance!!
Last edited by Benjamin on Thu Apr 30, 2009 1:29 am, edited 1 time in total.
Reason: Added code tags, type = php.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: What's the problem?

Post by Benjamin »

You are missing a semi-colon on line 8. The reason you are getting a blank page is more than likely because your installation of PHP has error reporting turned off. You are going to want to find your php.ini file and locate the error_reporting and display_error settings. Once you turn those on, PHP will tell you what the errors are.
s2009
Forum Newbie
Posts: 20
Joined: Thu Apr 30, 2009 1:20 am

Re: What's the problem?

Post by s2009 »

thanks for ur prompt reply.

Even after giving semicolon and changing the settings in php.ini configuration files for error_reporting as Yes. It is still displaying the blank page.

What should I do?

Please help me.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: What's the problem?

Post by Benjamin »

Put this in a file and post the output please:

Code: Select all

 
hello 
<?php echo "world"; ?>
 
Also, try testing your php installation:

Code: Select all

 
<?php
phpinfo();
 
s2009
Forum Newbie
Posts: 20
Joined: Thu Apr 30, 2009 1:20 am

Re: What's the problem?

Post by s2009 »

Thanks for your reply

When executing the first code of statements it is not displaying anything in the Internet Explorer but in the Mozilla FireFox it is displaying just hello.

But when the second code of statements is executed it is not displaying anything.

Now what should I do?

Please help me out
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: What's the problem?

Post by Benjamin »

What is the address in your browser when you view these files?
s2009
Forum Newbie
Posts: 20
Joined: Thu Apr 30, 2009 1:20 am

Re: What's the problem?

Post by s2009 »

Thanks for all your replies.

The address of the Browser (Mozila FireFox) is :

file:///C:/Documents%20and%20Settings/Admin/Desktop/a.php
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: What's the problem?

Post by Benjamin »

PHP code is not processed when you access a file directly. You need to install a webserver as well as PHP. Please have a look at xamp because it will install this for you:

http://www.apachefriends.org/en/xampp-windows.html

Once you have it up and running, you can view webpages locally by accessing http://localhost/pagename.php in your browser.
s2009
Forum Newbie
Posts: 20
Joined: Thu Apr 30, 2009 1:20 am

Re: What's the problem?

Post by s2009 »

Thanks for your reply.

I have installed the WAMP server.


But still i am not able to execute my PHP files.


Now what should I do to execute my PHP files?


Please help me out.

Thanks in advance!!
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: What's the problem?

Post by susrisha »

you need to place your file in the root directory or its subdirectories of the server.
If its WAMP that you are using, i beleive the root folder will be www

goes like this..
save your file in the following location
path_to_www/yourfile.php

Access the same through the browser as
http://localhost/yourfile.php

And let us know what the output is.
s2009
Forum Newbie
Posts: 20
Joined: Thu Apr 30, 2009 1:20 am

Re: What's the problem?

Post by s2009 »

susrisha wrote:you need to place your file in the root directory or its subdirectories of the server.
If its WAMP that you are using, i beleive the root folder will be www

goes like this..
save your file in the following location
path_to_www/yourfile.php

Access the same through the browser as
http://localhost/yourfile.php

And let us know what the output is.

Thanks for your reply.

It is displaying "The page cannot be found".

Please note that the WAMP server is put online only.

What should I do to run my PHP files?

Please please help me out.

Thanks in advance!!
watson516
Forum Contributor
Posts: 198
Joined: Mon Mar 20, 2006 9:19 pm
Location: Hamilton, Ontario

Re: What's the problem?

Post by watson516 »

If your wamp server is running then you should make sure that your file is in the correct directory (C:\wamp\www by default). Then just open up a web browser and type in localhost.
Last edited by watson516 on Fri May 01, 2009 12:21 pm, edited 1 time in total.
user___
Forum Contributor
Posts: 297
Joined: Tue Dec 05, 2006 3:05 pm

Re: What's the problem?

Post by user___ »

Read this for Windows:
http://www.php-mysql-tutorial.com/wikis ... mysql.aspx

There are a lot of tutorials for that on the Internet.
s2009
Forum Newbie
Posts: 20
Joined: Thu Apr 30, 2009 1:20 am

Re: What's the problem?

Post by s2009 »

watson516 wrote:If your wamp server is running then you should make sure that your file is in the correct directory (C:\wamp\www by default). Then just open up a web browser and type in localhost.
Thanks for your prompt reply.

I have saved it in the correct directory only but when I am trying to execute the file by using the localhost command it is displaying the following error page:

The page cannot be found
The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.

Please try the following:

* If you typed the page address in the Address bar, make sure that it is spelled correctly.
* Open the localhost home page, and then look for links to the information you want.
* Click the Back button to try another link.

HTTP 404 - File not found
Internet Information Services

Technical Information (for support personnel)

* More information:
Microsoft Support

Please reply me what the error is and how to detect it?

Thanks in advance!!!
watson516
Forum Contributor
Posts: 198
Joined: Mon Mar 20, 2006 9:19 pm
Location: Hamilton, Ontario

Re: What's the problem?

Post by watson516 »

A 404 error means that the file isn't there.

Are you running an IIS server or Apache? WAMP is apache. That error you posted appears to be from an IIS server (I could be wrong but the whole Internet Information Services kind of gives it away)

If you're not running wamp, then you need to save the file in whatever location IIS is looking at. If you're running multiple web servers at once, close down the others and just run wamp.
Post Reply