FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » PHP Runs In WinXP Command Window But Not In Browser
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
PHP Runs In WinXP Command Window But Not In Browser [message #173321] Sun, 03 April 2011 11:54 Go to next message
Peter Lauren is currently offline  Peter Lauren
Messages: 48
Registered: April 2011
Karma: 0
Member
I am using Windows XP have installed WAMP and PHP as outlined here
http://www.wampserver.com/en/
and have set my search path so that I need only type
php -f PHPExamples.php
and the PHP code runs fine. However, I have not managed to get it to
run in my FireFox/3.5.9 browser. When I make a simple file with the
following contents
<html>
<body>

<?php
$txt1="Hello World!";
$txt2="What a nice day!";

echo $txt1 . " " . $txt2 . " " . strlen("Hello world!") . " " .
strpos("Hello world!","world");
?>

</body>
</html>

name it Examples.php and call it with a button thus
<a href="Examples.php">PHP</a>

I just get a blank page.

I would be grateful if someone could tell me what I am doing wrong.

Thanks,
Peter.
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173322 is a reply to message #173321] Sun, 03 April 2011 12:03 Go to previous messageGo to next message
Luuk is currently offline  Luuk
Messages: 329
Registered: September 2010
Karma: 0
Senior Member
On 03-04-2011 13:54, Peter Lauren wrote:
> I am using Windows XP have installed WAMP and PHP as outlined here
> http://www.wampserver.com/en/
> and have set my search path so that I need only type
> php -f PHPExamples.php
> and the PHP code runs fine. However, I have not managed to get it to
> run in my FireFox/3.5.9 browser. When I make a simple file with the
> following contents
> <html>
> <body>
>
> <?php
> $txt1="Hello World!";
> $txt2="What a nice day!";
>
> echo $txt1 . " " . $txt2 . " " . strlen("Hello world!") . " " .
> strpos("Hello world!","world");
> ?>
>
> </body>
> </html>
>
> name it Examples.php and call it with a button thus
> <a href="Examples.php">PHP</a>
>
> I just get a blank page.
>
> I would be grateful if someone could tell me what I am doing wrong.
>
> Thanks,
> Peter.

how are you looking into this page?

what happens if you point browser to:
http://localhost/Examples.php

--
Luuk
Re: PHP runs in WinXP command window but not in browser [message #173323 is a reply to message #173321] Sun, 03 April 2011 12:39 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article
<c1edd513-4191-4d35-8325-9da8fd71f242(at)e21g2000yqe(dot)googlegroups(dot)com>,
Peter Lauren <peterdlauren(at)gmail(dot)com> wrote:

> I am using Windows XP have installed WAMP and PHP as outlined here
> http://www.wampserver.com/en/
> and have set my search path so that I need only type
> php -f PHPExamples.php
> and the PHP code runs fine. However, I have not managed to get it to
> run in my FireFox/3.5.9 browser. When I make a simple file with the
> following contents
> <html>
> <body>
>
> <?php
> $txt1="Hello World!";
> $txt2="What a nice day!";
>
> echo $txt1 . " " . $txt2 . " " . strlen("Hello world!") . " " .
> strpos("Hello world!","world");
> ?>
>
> </body>
> </html>
>
> name it Examples.php and call it with a button thus
> <a href="Examples.php">PHP</a>
>
> I just get a blank page.
>
> I would be grateful if someone could tell me what I am doing wrong.

PHP doesn't run in your browser, or indeed in anyone's browser. You need
to be running server software such as apache:

+--------------+ +----------------+
| | | |
| Your | | Web Server |
| machine +------- Internet -----------------+ running apache |
| and | | (your web page |
| browser | | is here too) |
| | | |
+--------------+ +----------------+

The web server can be your own machine but this doesn't alter the basic
approach.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173340 is a reply to message #173322] Mon, 04 April 2011 01:36 Go to previous messageGo to next message
Peter Lauren is currently offline  Peter Lauren
Messages: 48
Registered: April 2011
Karma: 0
Member
On Apr 3, 8:03 am, Luuk <L...@invalid.lan> wrote:
> On 03-04-2011 13:54, Peter Lauren wrote:
>
>
>
>> I am using Windows XP have installed WAMP and PHP as outlined here
>> http://www.wampserver.com/en/
>> and have set my search path so that I need only type
>> php -f PHPExamples.php
>> and the PHP code runs fine. However, I have not managed to get it to
>> run in my FireFox/3.5.9 browser. When I make a simple file with the
>> following contents
>> <html>
>> <body>
>
>> <?php
>> $txt1="Hello World!";
>> $txt2="What a nice day!";
>
>> echo $txt1 . " " . $txt2 . " " . strlen("Hello world!") . " " .
>> strpos("Hello world!","world");
>> ?>
>
>> </body>
>> </html>
>
>> name it Examples.php and call it with a button thus
>> <a href="Examples.php">PHP</a>
>
>> I just get a blank page.
>
>> I would be grateful if someone could tell me what I am doing wrong.
>
>> Thanks,
>> Peter.
>
> how are you looking into this page?
>
> what happens if you point browser to:http://localhost/Examples.php
>
> --
> Luuk

I get "Firefox can't establish a connection to the server at
localhost."

I don't think there's a problem accessing the file. It's just that it
doesn't display anything on my browser.

Thanks,
Peter.
Re: PHP runs in WinXP command window but not in browser [message #173341 is a reply to message #173323] Mon, 04 April 2011 01:42 Go to previous messageGo to next message
Peter Lauren is currently offline  Peter Lauren
Messages: 48
Registered: April 2011
Karma: 0
Member
On Apr 3, 8:39 am, Tim Streater <timstrea...@waitrose.com> wrote:
> In article
> <c1edd513-4191-4d35-8325-9da8fd71f...@e21g2000yqe.googlegroups.com>,
>  Peter Lauren <peterdlau...@gmail.com> wrote:
>
>
>
>> I am using Windows XP have installed WAMP and PHP as outlined here
>> http://www.wampserver.com/en/
>> and have set my search path so that I need only type
>> php -f PHPExamples.php
>> and the PHP code runs fine. However, I have not managed to get it to
>> run in my FireFox/3.5.9 browser. When I make a simple file with the
>> following contents
>> <html>
>> <body>
>
>> <?php
>> $txt1="Hello World!";
>> $txt2="What a nice day!";
>
>> echo $txt1 . " " . $txt2 . " " . strlen("Hello world!") . " " .
>> strpos("Hello world!","world");
>> ?>
>
>> </body>
>> </html>
>
>> name it Examples.php and call it with a button thus
>> <a href="Examples.php">PHP</a>
>
>> I just get a blank page.
>
>> I would be grateful if someone could tell me what I am doing wrong.
>
> PHP doesn't run in your browser, or indeed in anyone's browser. You need
> to be running server software such as apache:
>
> +--------------+                                  +----------------+
> |              |                                  |                |
> |   Your       |                                  | Web Server     |
> |  machine     +------- Internet -----------------+ running apache |
> |   and        |                                  | (your web page |
> | browser      |                                  | is here too)   |
> |              |                                  |                |
> +--------------+                                  +----------------+
>
> The web server can be your own machine but this doesn't alter the basic
> approach.
>
> --
> Tim
>
> "That excessive bail ought not to be required, nor excessive fines imposed,
> nor cruel and unusual punishments inflicted"  --  Bill of Rights 1689

I've been trying to run Apache which I downloaded from http://www.wampserver.com/en/.
The PHP command works fine in the command Window but I did see a
thread, on their forum, about Apache not starting. The forum
moderator said that could be because stuff like zonealarm, and
firewall/antivirus may cause a conflict. I have them running on my PC
but I don't want to turn them off and make my PC vulnerable to
hackers. Should I use a different version of Apache? Should I use
WAMP at all?

Thanks,
Peter.
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173343 is a reply to message #173340] Mon, 04 April 2011 01:54 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 4/3/2011 9:36 PM, Peter Lauren wrote:
> On Apr 3, 8:03 am, Luuk<L...@invalid.lan> wrote:
>> On 03-04-2011 13:54, Peter Lauren wrote:
>>
>>
>>
>>> I am using Windows XP have installed WAMP and PHP as outlined here
>>> http://www.wampserver.com/en/
>>> and have set my search path so that I need only type
>>> php -f PHPExamples.php
>>> and the PHP code runs fine. However, I have not managed to get it to
>>> run in my FireFox/3.5.9 browser. When I make a simple file with the
>>> following contents
>>> <html>
>>> <body>
>>
>>> <?php
>>> $txt1="Hello World!";
>>> $txt2="What a nice day!";
>>
>>> echo $txt1 . " " . $txt2 . " " . strlen("Hello world!") . " " .
>>> strpos("Hello world!","world");
>>> ?>
>>
>>> </body>
>>> </html>
>>
>>> name it Examples.php and call it with a button thus
>>> <a href="Examples.php">PHP</a>
>>
>>> I just get a blank page.
>>
>>> I would be grateful if someone could tell me what I am doing wrong.
>>
>>> Thanks,
>>> Peter.
>>
>> how are you looking into this page?
>>
>> what happens if you point browser to:http://localhost/Examples.php
>>
>> --
>> Luuk
>
> I get "Firefox can't establish a connection to the server at
> localhost."
>

Before you can display a the output from the PHP script, you need to be
able to connect to the server.

> I don't think there's a problem accessing the file. It's just that it
> doesn't display anything on my browser.
>
> Thanks,
> Peter.


It won't, if you aren't accessing it through a web server (or the most
it would display is the source code for your script).

To get it to work, you MUST have a running web server and be able to
connect to that web server.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: PHP runs in WinXP command window but not in browser [message #173344 is a reply to message #173341] Mon, 04 April 2011 01:55 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 4/3/2011 9:42 PM, Peter Lauren wrote:
> On Apr 3, 8:39 am, Tim Streater<timstrea...@waitrose.com> wrote:
>> In article
>> <c1edd513-4191-4d35-8325-9da8fd71f...@e21g2000yqe.googlegroups.com>,
>> Peter Lauren<peterdlau...@gmail.com> wrote:
>>
>>
>>
>>> I am using Windows XP have installed WAMP and PHP as outlined here
>>> http://www.wampserver.com/en/
>>> and have set my search path so that I need only type
>>> php -f PHPExamples.php
>>> and the PHP code runs fine. However, I have not managed to get it to
>>> run in my FireFox/3.5.9 browser. When I make a simple file with the
>>> following contents
>>> <html>
>>> <body>
>>
>>> <?php
>>> $txt1="Hello World!";
>>> $txt2="What a nice day!";
>>
>>> echo $txt1 . " " . $txt2 . " " . strlen("Hello world!") . " " .
>>> strpos("Hello world!","world");
>>> ?>
>>
>>> </body>
>>> </html>
>>
>>> name it Examples.php and call it with a button thus
>>> <a href="Examples.php">PHP</a>
>>
>>> I just get a blank page.
>>
>>> I would be grateful if someone could tell me what I am doing wrong.
>>
>> PHP doesn't run in your browser, or indeed in anyone's browser. You need
>> to be running server software such as apache:
>>
>> +--------------+ +----------------+
>> | | | |
>> | Your | | Web Server |
>> | machine +------- Internet -----------------+ running apache |
>> | and | | (your web page |
>> | browser | | is here too) |
>> | | | |
>> +--------------+ +----------------+
>>
>> The web server can be your own machine but this doesn't alter the basic
>> approach.
>>
>> --
>> Tim
>>
>> "That excessive bail ought not to be required, nor excessive fines imposed,
>> nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
>
> I've been trying to run Apache which I downloaded from http://www.wampserver.com/en/.
> The PHP command works fine in the command Window but I did see a
> thread, on their forum, about Apache not starting. The forum
> moderator said that could be because stuff like zonealarm, and
> firewall/antivirus may cause a conflict. I have them running on my PC
> but I don't want to turn them off and make my PC vulnerable to
> hackers. Should I use a different version of Apache? Should I use
> WAMP at all?
>
> Thanks,
> Peter.

Did you try asking in their forum? They provided the advice; they
should be able to tell you how to solve it.

And please note that this is a PHP forum - not an Apache setup forum!

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173347 is a reply to message #173340] Mon, 04 April 2011 08:53 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article
<d1db1616-5fe8-403a-a782-4b3f2061ba7a(at)m13g2000yqb(dot)googlegroups(dot)com>,
Peter Lauren <peterdlauren(at)gmail(dot)com> wrote:

> On Apr 3, 8:03
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173348 is a reply to message #173343] Mon, 04 April 2011 09:41 Go to previous messageGo to next message
crankypuss is currently offline  crankypuss
Messages: 147
Registered: March 2011
Karma: 0
Senior Member
Jerry Stuckle <jstucklex(at)attglobal(dot)net> wrote:

> On 4/3/2011 9:36 PM, Peter Lauren wrote:
>> On Apr 3, 8:03 am, Luuk<L...@invalid.lan> wrote:
>>> On 03-04-2011 13:54, Peter Lauren wrote:
>>>
>>>
>>>
>>>> I am using Windows XP have installed WAMP and PHP as outlined here
>>>> http://www.wampserver.com/en/
>>>> and have set my search path so that I need only type
>>>> php -f PHPExamples.php
>>>> and the PHP code runs fine. However, I have not managed to get it to
>>>> run in my FireFox/3.5.9 browser. When I make a simple file with the
>>>> following contents
>>>> <html>
>>>> <body>
>>>
>>>> <?php
>>>> $txt1="Hello World!";
>>>> $txt2="What a nice day!";
>>>
>>>> echo $txt1 . " " . $txt2 . " " . strlen("Hello world!") . " " .
>>>> strpos("Hello world!","world");
>>>> ?>
>>>
>>>> </body>
>>>> </html>
>>>
>>>> name it Examples.php and call it with a button thus
>>>> <a href="Examples.php">PHP</a>
>>>
>>>> I just get a blank page.
>>>
>>>> I would be grateful if someone could tell me what I am doing wrong.
>>>
>>>> Thanks,
>>>> Peter.
>>>
>>> how are you looking into this page?
>>>
>>> what happens if you point browser to:http://localhost/Examples.php
>>>
>>> --
>>> Luuk
>>
>> I get "Firefox can't establish a connection to the server at
>> localhost."
>>
>
> Before you can display a the output from the PHP script, you need to be
> able to connect to the server.
>
>> I don't think there's a problem accessing the file. It's just that it
>> doesn't display anything on my browser.
>>
>> Thanks,
>> Peter.
>
>
> It won't, if you aren't accessing it through a web server (or the most
> it would display is the source code for your script).
>
> To get it to work, you MUST have a running web server and be able to
> connect to that web server.

....which means you have to set up apache's configuration file. I get
the idea that the OP has installed WAMP but hasn't configured apache,
or maybe hasn't set up the hosts file, or maybe both.

Peter: Have you edited apache's configuration file "httpd.conf"?
There's a menu item for that, left-click the WAMP taskbar icon, select
Apache, select httpd.conf; unless you at least modify the DocumentRoot
specification, it'll never find your localhost's root document
directory.

For apache-specific stuff (like configuration details), you probably
ought to go to alt.apache.configuration

--
no aluminum siding offers today
Re: PHP runs in WinXP command window but not in browser [message #173349 is a reply to message #173341] Mon, 04 April 2011 09:48 Go to previous messageGo to next message
crankypuss is currently offline  crankypuss
Messages: 147
Registered: March 2011
Karma: 0
Senior Member
Peter Lauren <peterdlauren(at)gmail(dot)com> wrote:

> On Apr 3, 8:39 am, Tim Streater <timstrea...@waitrose.com> wrote:
>> In article
>> <c1edd513-4191-4d35-8325-9da8fd71f...@e21g2000yqe.googlegroups.com>,
>>  Peter Lauren <peterdlau...@gmail.com> wrote:
>>
>>
>>
>>> I am using Windows XP have installed WAMP and PHP as outlined here
>>> http://www.wampserver.com/en/
>>> and have set my search path so that I need only type
>>> php -f PHPExamples.php
>>> and the PHP code runs fine. However, I have not managed to get it to
>>> run in my FireFox/3.5.9 browser. When I make a simple file with the
>>> following contents
>>> <html>
>>> <body>
>>
>>> <?php
>>> $txt1="Hello World!";
>>> $txt2="What a nice day!";
>>
>>> echo $txt1 . " " . $txt2 . " " . strlen("Hello world!") . " " .
>>> strpos("Hello world!","world");
>>> ?>
>>
>>> </body>
>>> </html>
>>
>>> name it Examples.php and call it with a button thus
>>> <a href="Examples.php">PHP</a>
>>
>>> I just get a blank page.
>>
>>> I would be grateful if someone could tell me what I am doing wrong.
>>
>> PHP doesn't run in your browser, or indeed in anyone's browser. You need
>> to be running server software such as apache:
>>
>> +--------------+                                  +----------------+
>> |              |                                  |                |
>> |   Your       |                                  | Web Server     |
>> |  machine     +------- Internet -----------------+ running apache |
>> |   and        |                                  | (your web page |
>> | browser      |                                  | is here too)   |
>> |              |                                  |                |
>> +--------------+                                  +----------------+
>>
>> The web server can be your own machine but this doesn't alter the basic
>> approach.
>>
>> --
>> Tim
>>
>> "That excessive bail ought not to be required, nor excessive fines imposed,
>> nor cruel and unusual punishments inflicted"  --  Bill of Rights 1689
>
> I've been trying to run Apache which I downloaded from http://www.wampserver.com/en/.
> The PHP command works fine in the command Window but I did see a
> thread, on their forum, about Apache not starting. The forum
> moderator said that could be because stuff like zonealarm, and
> firewall/antivirus may cause a conflict. I have them running on my PC
> but I don't want to turn them off and make my PC vulnerable to
> hackers. Should I use a different version of Apache? Should I use
> WAMP at all?
>
> Thanks,
> Peter.

Before you can get PHP to be executed by your local Apache server in
response to a browser request, you have to configure the Apache
server. It sounds like you haven't done that part yet. You might
also have to modify the windows "hosts" file. And be careful not to
make your WAMP/Apache server a security hole that invites the entire
internet world into your PC. alt.apache.configuration is the group to
ask apache configuration questions in, if you decide that's what you
need.

--
no aluminum siding offers today
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173356 is a reply to message #173321] Mon, 04 April 2011 17:19 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On Sun, 03 Apr 2011 04:54:02 -0700, Peter Lauren wrote:

> I am using Windows XP have installed WAMP and PHP as outlined here
> http://www.wampserver.com/en/ ........ [deleted]

Simplified explanation for how php works on a webserver:

1) A surfer users their web browser to send a request to a webserver at
"http://<host>/<path>/<file>"

("<file>" is usually somename.php)

2) The webserver at "<host>" determines what file in it's filesystem
"<path>/<file>" refers to.

3) The webserver at "<host>" determines that the file in it's filesystem
that "<path>/<file>" refers to should be parsed for php code before
sending it to the surfers browser.

4) The webserver at "<host>" sends the actual file that "<path>/<file>"
refers to to the php script processor, and then sends the output from the
php script processor back to the web browser.

You need to check that your web server is working. If it's on the same
machine as you are developing code on, try using your web browser to
connect to:

a) http://localhost/

or

b) http://127.0.0.1/

(If it is some other machine, modify the (a) host name or (b) ip address
as appropriate)

If your web server is working, you should get a default page announcing
itself as apache (as you have installed wamp).

If you don't get a "welcome to apache webserver" page, then you need to
start the webserver. That is beyond the scope of my knowledge, try
googling "wamp start webserver process"

Once the web server is working, you next need to locate where the
webserver root is. This is not the root of your hard disc (or it damn
well shouldn't be) and will be specified in a configuration file. Again,
google is your friend.

In the document root, insert a file called phpinfo.php with the text
between the cutlines below:

---8<--- cut here ---8<---
<?php phpinfo(); ?>
---8<--- cut here ---8<---

Then connect to the following url:

http://<(a) server host name or (b) server ip address>/phpinfo.php

And if you have been successful, and the web server is running, and your
configuration is correct, you will get displayed on your screen a large
amount of information about the php and web server configuration.

Rgds

Denis McMahon
Re: PHP runs in WinXP command window but not in browser [message #173359 is a reply to message #173341] Mon, 04 April 2011 22:31 Go to previous messageGo to next message
Peter H. Coffin is currently offline  Peter H. Coffin
Messages: 245
Registered: September 2010
Karma: 0
Senior Member
On Sun, 3 Apr 2011 18:42:45 -0700 (PDT), Peter Lauren wrote:
> On Apr 3, 8:39?am, Tim Streater <timstrea...@waitrose.com> wrote:
>> The web server can be your own machine but this doesn't alter the basic
>> approach.
>
> I've been trying to run Apache which I downloaded from http://www.wampserver.com/en/.
> The PHP command works fine in the command Window but I did see a
> thread, on their forum, about Apache not starting. The forum
> moderator said that could be because stuff like zonealarm, and
> firewall/antivirus may cause a conflict.

If you've misconfigured them, maybe. Every sane firewall, including
every out-of-the-box one of the major vendors excepts localhost
connections from blocking, because many applications do that to
communicate internally, since Windows doesn't have OS sockets. *USUALLY*
a suggestion that a firewall is causing a problem on a local machines is
an indication that the speaker doesn't really have a clue and isn't
interested in the problem.

> I have them running on my PC but I don't want to turn them off and
> make my PC vulnerable to hackers. Should I use a different version of
> Apache? Should I use WAMP at all?

WAMP's a perfectly reasonable thing to use. You'll need to make sure
that you've got the services started properly. Which means going back to
the WAMP setup and making sure you've dotted all the tees and crossed all
the eyes. Get that Apache working THEN worry about making PHP hook up to
it. It may be as simple as "you haven't turned it on yet".

--
If any foreign minister begins to defend to the death a "peace
conference," you can be sure his government has already placed its
orders for new battleships and airplanes. -Joseph Stalin
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173374 is a reply to message #173356] Tue, 05 April 2011 18:36 Go to previous messageGo to next message
Jim Higgins is currently offline  Jim Higgins
Messages: 20
Registered: November 2010
Karma: 0
Junior Member
On 04 Apr 2011 17:19:39 GMT, Denis McMahon
<denis(dot)m(dot)f(dot)mcmahon(at)gmail(dot)com> wrote:

> On Sun, 03 Apr 2011 04:54:02 -0700, Peter Lauren wrote:
>
>> I am using Windows XP have installed WAMP and PHP as outlined here
>> http://www.wampserver.com/en/ ........ [deleted]
>
> Simplified explanation for how php works on a webserver:
>
> 1) A surfer users their web browser to send a request to a webserver at
> "http://<host>/<path>/<file>"
>
> ("<file>" is usually somename.php)
>
> 2) The webserver at "<host>" determines what file in it's filesystem
> "<path>/<file>" refers to.
>
> 3) The webserver at "<host>" determines that the file in it's filesystem
> that "<path>/<file>" refers to should be parsed for php code before
> sending it to the surfers browser.
>
> 4) The webserver at "<host>" sends the actual file that "<path>/<file>"
> refers to to the php script processor, and then sends the output from the
> php script processor back to the web browser.
>
> You need to check that your web server is working. If it's on the same
> machine as you are developing code on, try using your web browser to
> connect to:
>
> a) http://localhost/
>
> or
>
> b) http://127.0.0.1/
>
> (If it is some other machine, modify the (a) host name or (b) ip address
> as appropriate)
>
> If your web server is working, you should get a default page announcing
> itself as apache (as you have installed wamp).
>
> If you don't get a "welcome to apache webserver" page, then you need to
> start the webserver. That is beyond the scope of my knowledge, try
> googling "wamp start webserver process"
>
> Once the web server is working, you next need to locate where the
> webserver root is. This is not the root of your hard disc (or it damn
> well shouldn't be) and will be specified in a configuration file. Again,
> google is your friend.
>
> In the document root, insert a file called phpinfo.php with the text
> between the cutlines below:
>
> ---8<--- cut here ---8<---
> <?php phpinfo(); ?>
> ---8<--- cut here ---8<---
>
> Then connect to the following url:
>
> http://<(a) server host name or (b) server ip address>/phpinfo.php
>
> And if you have been successful, and the web server is running, and your
> configuration is correct, you will get displayed on your screen a large
> amount of information about the php and web server configuration.


I'm new to the group and the thread...

Denis, the above is good stuff - THANK YOU - but how does one
configure so that simply clicking on that phpinfo.php file results in
the same action as connecting to
http://localhost/phpinfo.php

The answer to that would make life so much simpler. Having to type
"http://localhost/" before every file name while trying to develop
something is a total pain in the butt.
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173375 is a reply to message #173374] Tue, 05 April 2011 20:07 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 4/5/2011 2:36 PM, Jim Higgins wrote:
> On 04 Apr 2011 17:19:39 GMT, Denis McMahon
> <denis(dot)m(dot)f(dot)mcmahon(at)gmail(dot)com> wrote:
>
>> On Sun, 03 Apr 2011 04:54:02 -0700, Peter Lauren wrote:
>>
>>> I am using Windows XP have installed WAMP and PHP as outlined here
>>> http://www.wampserver.com/en/ ........ [deleted]
>>
>> Simplified explanation for how php works on a webserver:
>>
>> 1) A surfer users their web browser to send a request to a webserver at
>> "http://<host>/<path>/<file>"
>>
>> ("<file>" is usually somename.php)
>>
>> 2) The webserver at "<host>" determines what file in it's filesystem
>> "<path>/<file>" refers to.
>>
>> 3) The webserver at "<host>" determines that the file in it's filesystem
>> that "<path>/<file>" refers to should be parsed for php code before
>> sending it to the surfers browser.
>>
>> 4) The webserver at "<host>" sends the actual file that"<path>/<file>"
>> refers to to the php script processor, and then sends the output from the
>> php script processor back to the web browser.
>>
>> You need to check that your web server is working. If it's on the same
>> machine as you are developing code on, try using your web browser to
>> connect to:
>>
>> a) http://localhost/
>>
>> or
>>
>> b) http://127.0.0.1/
>>
>> (If it is some other machine, modify the (a) host name or (b) ip address
>> as appropriate)
>>
>> If your web server is working, you should get a default page announcing
>> itself as apache (as you have installed wamp).
>>
>> If you don't get a "welcome to apache webserver" page, then you need to
>> start the webserver. That is beyond the scope of my knowledge, try
>> googling "wamp start webserver process"
>>
>> Once the web server is working, you next need to locate where the
>> webserver root is. This is not the root of your hard disc (or it damn
>> well shouldn't be) and will be specified in a configuration file. Again,
>> google is your friend.
>>
>> In the document root, insert a file called phpinfo.php with the text
>> between the cutlines below:
>>
>> ---8<--- cut here ---8<---
>> <?php phpinfo(); ?>
>> ---8<--- cut here ---8<---
>>
>> Then connect to the following url:
>>
>> http://<(a) server host name or (b) server ip address>/phpinfo.php
>>
>> And if you have been successful, and the web server is running, and your
>> configuration is correct, you will get displayed on your screen a large
>> amount of information about the php and web server configuration.
>
>
> I'm new to the group and the thread...
>
> Denis, the above is good stuff - THANK YOU - but how does one
> configure so that simply clicking on that phpinfo.php file results in
> the same action as connecting to
> http://localhost/phpinfo.php
>
> The answer to that would make life so much simpler. Having to type
> "http://localhost/" before every file name while trying to develop
> something is a total pain in the butt.

You don't. You MUST use a web server to serve the php pages. But then
that's what links and bookmarks are for.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173377 is a reply to message #173374] Tue, 05 April 2011 22:01 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article <cqnmp6pjjps2kjlgb3h1j73u7alkj0jbfk(at)4ax(dot)com>,
Jim Higgins <invalid(at)invalid(dot)invalid> wrote:

> On 04 Apr 2011 17:19:39 GMT, Denis McMahon
> <denis(dot)m(dot)f(dot)mcmahon(at)gmail(dot)com> wrote:

>> Then connect to the following url:
>>
>> http://<(a) server host name or (b) server ip address>/phpinfo.php
>>
>> And if you have been successful, and the web server is running, and your
>> configuration is correct, you will get displayed on your screen a large
>> amount of information about the php and web server configuration.
>
>
> I'm new to the group and the thread...
>
> Denis, the above is good stuff - THANK YOU - but how does one
> configure so that simply clicking on that phpinfo.php file results in
> the same action as connecting to
> http://localhost/phpinfo.php
>
> The answer to that would make life so much simpler. Having to type
> "http://localhost/" before every file name while trying to develop
> something is a total pain in the butt.

You're expecting things to work by magic. How do you suppose that
double-clicking a file is going to make the results display in a window
of another application?

I gave, in an earlier post, a simple ascii-art picture of how web pages
are served up. The only way you can avoid that [1] is if the file
extension is such that double-clicking the file opens it in a browser.
But in that case, *no* PHP execution will occur, the page will be
treated as if it contains *only* html. Browsers know nothing about PHP
and cannot do anything with it. The web server, by contrast, has as one
of its purposes to feed a requested page to the PHP interpreter, and
then feed the results of that back to your browser. Once the PHP has
run, there is no PHP left in the output stream, only the results.

[1] At least, this works on the Mac, I'm assuming the same is true for
other platforms.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173378 is a reply to message #173374] Tue, 05 April 2011 23:27 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On Tue, 05 Apr 2011 18:36:08 +0000, Jim Higgins wrote:

> Denis, the above is good stuff - THANK YOU - but how does one configure
> so that simply clicking on that phpinfo.php file results in the same
> action as connecting to
> http://localhost/phpinfo.php

You can't.

Well, possibly you can, but it's more complex than I can set up quickly.
You'd need to code something that would generate an appropriate url and
pass it to your web browser, and to generate the url you'd need to know
where under your document root the file was, so you would have to:

1) find the actual file system path to the file
2) compare to the file system path for docroot
3) if the leftmost part of the filesystem path matches the docroot path,
remove it
3a) convert from windows to url format paths if appropriate
4) add the http://localhost/ in place of the removed part
5) call the web browser with the url

eg if the file is:

c:\documents and settings\jim higgins\testing\htdocs\test1\phpinfo.php

and the apache docroot is:

c:\documents and settings\jim higgins\testing\htdocs

then you need to invoke a browser with the url:

http://localhost/test1/phpinfo.php

It's probably possibly on a linux box with a bit of scripting, I have no
idea how to do it on a windows box, but personally, I want php files on
the server to open in my text editor when I double click them.

Rgds

Denis McMahon
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173380 is a reply to message #173348] Wed, 06 April 2011 20:36 Go to previous messageGo to next message
Peter Lauren is currently offline  Peter Lauren
Messages: 48
Registered: April 2011
Karma: 0
Member
On Apr 4, 5:41 am, crankypuss <n...@email.thanks> wrote:
> Jerry Stuckle <jstuck...@attglobal.net> wrote:
>> On 4/3/2011 9:36 PM, Peter Lauren wrote:
>>> On Apr 3, 8:03 am, Luuk<L...@invalid.lan>  wrote:
>>>> On 03-04-2011 13:54, Peter Lauren wrote:
>
>>>> > I am using Windows XP have installed WAMP and PHP as outlined here
>>>> >http://www.wampserver.com/en/
>>>> > and have set my search path so that I need only type
>>>> > php -f PHPExamples.php
>>>> > and the PHP code runs fine. However, I have not managed to get it to
>>>> > run in my FireFox/3.5.9 browser. When I make a simple file with the
>>>> > following contents
>>>> > <html>
>>>> > <body>
>
>>>> > <?php
>>>> > $txt1="Hello World!";
>>>> > $txt2="What a nice day!";
>
>>>> > echo $txt1 . " " . $txt2 . " " . strlen("Hello world!") . " " .
>>>> > strpos("Hello world!","world");
>>>> > ?>
>
>>>> > </body>
>>>> > </html>
>
>>>> > name it Examples.php and call it with a button thus
>>>> > <a href="Examples.php">PHP</a>
>
>>>> > I just get a blank page.
>
>>>> > I would be grateful if someone could tell me what I am doing wrong.
>
>>>> > Thanks,
>>>> > Peter.
>
>>>> how are you looking into this page?
>
>>>> what happens if you point browser to:http://localhost/Examples.php
>
>>>> --
>>>> Luuk
>
>>> I get "Firefox can't establish a connection to the server at
>>> localhost."
>
>> Before you can display a the output from the PHP script, you need to be
>> able to connect to the server.
>
>>> I don't think there's a problem accessing the file.  It's just that it
>>> doesn't display anything on my browser.
>
>>> Thanks,
>>> Peter.
>
>> It won't, if you aren't accessing it through a web server (or the most
>> it would display is the source code for your script).
>
>> To get it to work, you MUST have a running web server and be able to
>> connect to that web server.
>
> ...which means you have to set up apache's configuration file.  I get
> the idea that the OP has installed WAMP but hasn't configured apache,
> or maybe hasn't set up the hosts file, or maybe both.
>
> Peter: Have you edited apache's configuration file "httpd.conf"?
> There's a menu item for that, left-click the WAMP taskbar icon, select
> Apache, select httpd.conf; unless you at least modify the DocumentRoot
> specification, it'll never find your localhost's root document
> directory.

Actually that's another problem I have with the WAMP I downloaded from
wampserver.com. I double (left) click on the wampmanager icon on the
desktop and nothing happens. However I opened httpd.conf with NotePad
and saw DocumentRoot specified by
DocumentRoot "c:/wamp/www/"
Is the root document the Desktop virtual folder which contains the My
Documents, My Computer, My Network Places and Recycle Bin virtual
folders? Thanks.

>
> For apache-specific stuff (like configuration details), you probably
> ought to go to alt.apache.configuration

Thanks. I've checked that out. Thank you so much for your help.
Re: PHP runs in WinXP command window but not in browser [message #173381 is a reply to message #173349] Wed, 06 April 2011 20:43 Go to previous messageGo to next message
Peter Lauren is currently offline  Peter Lauren
Messages: 48
Registered: April 2011
Karma: 0
Member
On Apr 4, 5:48 am, crankypuss <n...@email.thanks> wrote:
 alt.apache.configuration is the group to
> ask apache configuration questions in, if you decide that's what you
> need.
>

Thank you for letting me know about that group. It's just what I was
looking for.
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173382 is a reply to message #173380] Wed, 06 April 2011 21:14 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article
<6b9c9648-605e-4317-aabd-98e6d8cfa1bc(at)j17g2000vbr(dot)googlegroups(dot)com>,
Peter Lauren <peterdlauren(at)gmail(dot)com> wrote:

> Actually that's another problem I have with the WAMP I downloaded from
> wampserver.com. I double (left) click on the wampmanager icon on the
> desktop and nothing happens. However I opened httpd.conf with NotePad
> and saw DocumentRoot specified by
> DocumentRoot "c:/wamp/www/"
> Is the root document the Desktop virtual folder which contains the My
> Documents, My Computer, My Network Places and Recycle Bin virtual
> folders? Thanks.

The document root is where you put your web pages. If you have
wiggy.html located at:

c:/wamp/www/wiggy.html

then your browser can ask for it at:

http://localhost/wiggy.html

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173383 is a reply to message #173380] Wed, 06 April 2011 21:21 Go to previous messageGo to next message
Mr. B-o-B is currently offline  Mr. B-o-B
Messages: 42
Registered: April 2011
Karma: 0
Member
Peter Lauren cried from the depths of the abyss...

> I double (left) click on the wampmanager icon on the
> desktop and nothing happens.

Don't double click. Just *single* left click the icon for the prize.

Mr. B-o-B
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173384 is a reply to message #173356] Thu, 07 April 2011 03:18 Go to previous messageGo to next message
Peter Lauren is currently offline  Peter Lauren
Messages: 48
Registered: April 2011
Karma: 0
Member
On Apr 4, 1:19 pm, Denis McMahon <denis.m.f.mcma...@gmail.com> wrote:
> On Sun, 03 Apr 2011 04:54:02 -0700, Peter Lauren wrote:
>> I am using Windows XP have installed WAMP and PHP as outlined here
>> http://www.wampserver.com/en/........ [deleted]
>
> Simplified explanation for how php works on a webserver:
>
> 1) A surfer users their web browser to send a request to a webserver at
> "http://<host>/<path>/<file>"
>
> ("<file>" is usually somename.php)
>
> 2) The webserver at "<host>" determines what file in it's filesystem
> "<path>/<file>" refers to.
>
> 3) The webserver at "<host>" determines that the file in it's filesystem
> that "<path>/<file>" refers to should be parsed for php code before
> sending it to the surfers browser.
>
> 4) The webserver at "<host>" sends the actual file that "<path>/<file>"
> refers to to the php script processor, and then sends the output from the
> php script processor back to the web browser.
>
> You need to check that your web server is working. If it's on the same
> machine as you are developing code on, try using your web browser to
> connect to:
>
> a)http://localhost/
>
> or
>
> b)http://127.0.0.1/
>
> (If it is some other machine, modify the (a) host name or (b) ip address
> as appropriate)
>
> If your web server is working, you should get a default page announcing
> itself as apache (as you have installed wamp).
>
> If you don't get a "welcome to apache webserver" page, then you need to
> start the webserver. That is beyond the scope of my knowledge, try
> googling "wamp start webserver process"
>
> Once the web server is working, you next need to locate where the
> webserver root is. This is not the root of your hard disc (or it damn
> well shouldn't be) and will be specified in a configuration file. Again,
> google is your friend.
>
> In the document root, insert a file called phpinfo.php with the text
> between the cutlines below:
>
> ---8<--- cut here ---8<---
> <?php phpinfo(); ?>
> ---8<--- cut here ---8<---
>
> Then connect to the following url:
>
> http://<(a) server host name or (b) server ip address>/phpinfo.php
>
> And if you have been successful, and the web server is running, and your
> configuration is correct, you will get displayed on your screen a large
> amount of information about the php and web server configuration.
>
> Rgds
>
> Denis McMahon

Hi Denis,

On Win XP I went to Start:Run and ran
net start wampapache

When I go to http://localhost/, I get a page with the wampserver icon
and a bunch of stuff including the following.

Server Configuration

Apache Version :
2.2.17
PHP Version :
5.3.5
Loaded Extensions :

* Core
* bcmath
* calendar
[and several other extensions]

MySQL Version :
5.5.8
---------------------------------------------------------------

The httpd.conf file gives DocumentRoot "c:/wamp/www/"

However when I just have <a href="index.php">PHP</a>
on my web page, I get a message that it cannot find the file because
it is looking in the folder that contains the html file. When I use
<a href="c:/wamp/www/index.php">PHP</a>
I get an alert message "Firefox doesn't know how to open this address,
because the protocol (c) isn't associated with any program"

Thanks,
Peter.
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173385 is a reply to message #173356] Thu, 07 April 2011 03:19 Go to previous messageGo to next message
Peter Lauren is currently offline  Peter Lauren
Messages: 48
Registered: April 2011
Karma: 0
Member
On Apr 4, 1:19 pm, Denis McMahon <denis.m.f.mcma...@gmail.com> wrote:
> On Sun, 03 Apr 2011 04:54:02 -0700, Peter Lauren wrote:
>> I am using Windows XP have installed WAMP and PHP as outlined here
>> http://www.wampserver.com/en/........ [deleted]
>
> Simplified explanation for how php works on a webserver:
>
> 1) A surfer users their web browser to send a request to a webserver at
> "http://<host>/<path>/<file>"
>
> ("<file>" is usually somename.php)
>
> 2) The webserver at "<host>" determines what file in it's filesystem
> "<path>/<file>" refers to.
>
> 3) The webserver at "<host>" determines that the file in it's filesystem
> that "<path>/<file>" refers to should be parsed for php code before
> sending it to the surfers browser.
>
> 4) The webserver at "<host>" sends the actual file that "<path>/<file>"
> refers to to the php script processor, and then sends the output from the
> php script processor back to the web browser.
>
> You need to check that your web server is working. If it's on the same
> machine as you are developing code on, try using your web browser to
> connect to:
>
> a)http://localhost/
>
> or
>
> b)http://127.0.0.1/
>
> (If it is some other machine, modify the (a) host name or (b) ip address
> as appropriate)
>
> If your web server is working, you should get a default page announcing
> itself as apache (as you have installed wamp).
>
> If you don't get a "welcome to apache webserver" page, then you need to
> start the webserver. That is beyond the scope of my knowledge, try
> googling "wamp start webserver process"
>
> Once the web server is working, you next need to locate where the
> webserver root is. This is not the root of your hard disc (or it damn
> well shouldn't be) and will be specified in a configuration file. Again,
> google is your friend.
>
> In the document root, insert a file called phpinfo.php with the text
> between the cutlines below:
>
> ---8<--- cut here ---8<---
> <?php phpinfo(); ?>
> ---8<--- cut here ---8<---
>
> Then connect to the following url:
>
> http://<(a) server host name or (b) server ip address>/phpinfo.php
>
> And if you have been successful, and the web server is running, and your
> configuration is correct, you will get displayed on your screen a large
> amount of information about the php and web server configuration.
>
> Rgds
>
> Denis McMahon

Hi Denis,

On Win XP I went to Start:Run and ran
net start wampapache

When I go to http://localhost/, I get a page with the wampserver icon
and a bunch of stuff including the following.

Server Configuration

Apache Version :
2.2.17
PHP Version :
5.3.5
Loaded Extensions :

* Core
* bcmath
* calendar
[and several other extensions]

MySQL Version :
5.5.8
---------------------------------------------------------------

The httpd.conf file gives DocumentRoot "c:/wamp/www/"

However when I just have <a href="index.php">PHP</a>
on my web page, I get a message that it cannot find the file because
it is looking in the folder that contains the html file. When I use
<a href="c:/wamp/www/index.php">PHP</a>
I get an alert message "Firefox doesn't know how to open this address,
because the protocol (c) isn't associated with any program"

Thanks,
Peter.
Re: PHP runs in WinXP command window but not in browser [message #173386 is a reply to message #173359] Thu, 07 April 2011 03:40 Go to previous messageGo to next message
Peter Lauren is currently offline  Peter Lauren
Messages: 48
Registered: April 2011
Karma: 0
Member
Thanks for the info. It is reassuring that I don't need to invite the
world in on order to connect to the world. I thought that it should
be possible, and necessary, to have a firewall up when running a
server.

Thanks again,
Peter.

Peter H. Coffin wrote:
> On Sun, 3 Apr 2011 18:42:45 -0700 (PDT), Peter Lauren wrote:
>> On Apr 3, 8:39?am, Tim Streater <timstrea...@waitrose.com> wrote:
>>> The web server can be your own machine but this doesn't alter the basic
>>> approach.
>>
>> I've been trying to run Apache which I downloaded from http://www.wampserver.com/en/.
>> The PHP command works fine in the command Window but I did see a
>> thread, on their forum, about Apache not starting. The forum
>> moderator said that could be because stuff like zonealarm, and
>> firewall/antivirus may cause a conflict.
>
> If you've misconfigured them, maybe. Every sane firewall, including
> every out-of-the-box one of the major vendors excepts localhost
> connections from blocking, because many applications do that to
> communicate internally, since Windows doesn't have OS sockets. *USUALLY*
> a suggestion that a firewall is causing a problem on a local machines is
> an indication that the speaker doesn't really have a clue and isn't
> interested in the problem.
>
>> I have them running on my PC but I don't want to turn them off and
>> make my PC vulnerable to hackers. Should I use a different version of
>> Apache? Should I use WAMP at all?
>
> WAMP's a perfectly reasonable thing to use. You'll need to make sure
> that you've got the services started properly. Which means going back to
> the WAMP setup and making sure you've dotted all the tees and crossed all
> the eyes. Get that Apache working THEN worry about making PHP hook up to
> it. It may be as simple as "you haven't turned it on yet".
>
> --
> If any foreign minister begins to defend to the death a "peace
> conference," you can be sure his government has already placed its
> orders for new battleships and airplanes. -Joseph Stalin
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173387 is a reply to message #173382] Thu, 07 April 2011 03:54 Go to previous messageGo to next message
Peter Lauren is currently offline  Peter Lauren
Messages: 48
Registered: April 2011
Karma: 0
Member
On Apr 6, 5:14 pm, Tim Streater <timstrea...@waitrose.com> wrote:
>
> The document root is where you put your web pages. If you have
> wiggy.html located at:
>
> c:/wamp/www/wiggy.html
>
> then your browser can ask for it at:
>
> http://localhost/wiggy.html

Yes!!!!!!!!!!!!!!!!

That was the step that finally got it working. Thank you to everyone
who helped. Just a recap of what I did.
1/ Start:Run:net start wampapache
2/ Look at the httpd file and see where DocumentRoot is
DocumentRoot "c:/wamp/www/"
3/ Put my http files in c:/wamp/www/
4/ Put <a href="http://localhost/Examples.php">PHP</a> in my html
file.

Thanks again to everyone for their help.
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173388 is a reply to message #173383] Thu, 07 April 2011 04:00 Go to previous messageGo to next message
Peter Lauren is currently offline  Peter Lauren
Messages: 48
Registered: April 2011
Karma: 0
Member
On Apr 6, 5:21 pm, "Mr. B-o-B" <mr.chew.b...@gmail.com> wrote:
> Peter Lauren cried from the depths of the abyss...
>
>> I double (left) click on the wampmanager icon on the
>> desktop and nothing happens.
>
> Don't double click.  Just *single* left click the icon for the prize.
>
> Mr. B-o-B

Hi Mr. Bob, Well I'm out of the abyss now because I finally have PHP
code running on my browser (through the server). Unfortunately, the
single click worketh not for the wampmanager icon. Seems I don;t need
it anyway. I'm in business with the server.
Thanks,
Peter
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173390 is a reply to message #173387] Thu, 07 April 2011 08:08 Go to previous messageGo to next message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma: 0
Senior Member
In article
<1ed8923b-67cc-4be2-b471-55c92c09107c(at)w7g2000yqe(dot)googlegroups(dot)com>,
Peter Lauren <peterdlauren(at)gmail(dot)com> wrote:

> On Apr 6, 5:14
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173391 is a reply to message #173380] Thu, 07 April 2011 09:19 Go to previous messageGo to next message
crankypuss is currently offline  crankypuss
Messages: 147
Registered: March 2011
Karma: 0
Senior Member
Peter Lauren <peterdlauren(at)gmail(dot)com> wrote:

> On Apr 4, 5:41 am, crankypuss <n...@email.thanks> wrote:
>> Jerry Stuckle <jstuck...@attglobal.net> wrote:
>>> On 4/3/2011 9:36 PM, Peter Lauren wrote:
>>>> On Apr 3, 8:03 am, Luuk<L...@invalid.lan>  wrote:
>>>> > On 03-04-2011 13:54, Peter Lauren wrote:
>>
>>>> >> I am using Windows XP have installed WAMP and PHP as outlined here
>>>> >>http://www.wampserver.com/en/
>>>> >> and have set my search path so that I need only type
>>>> >> php -f PHPExamples.php
>>>> >> and the PHP code runs fine. However, I have not managed to get it to
>>>> >> run in my FireFox/3.5.9 browser. When I make a simple file with the
>>>> >> following contents
>>>> >> <html>
>>>> >> <body>
>>
>>>> >> <?php
>>>> >> $txt1="Hello World!";
>>>> >> $txt2="What a nice day!";
>>
>>>> >> echo $txt1 . " " . $txt2 . " " . strlen("Hello world!") . " " .
>>>> >> strpos("Hello world!","world");
>>>> >> ?>
>>
>>>> >> </body>
>>>> >> </html>
>>
>>>> >> name it Examples.php and call it with a button thus
>>>> >> <a href="Examples.php">PHP</a>
>>
>>>> >> I just get a blank page.
>>
>>>> >> I would be grateful if someone could tell me what I am doing wrong.
>>
>>>> >> Thanks,
>>>> >> Peter.
>>
>>>> > how are you looking into this page?
>>
>>>> > what happens if you point browser to:http://localhost/Examples.php
>>
>>>> > --
>>>> > Luuk
>>
>>>> I get "Firefox can't establish a connection to the server at
>>>> localhost."
>>
>>> Before you can display a the output from the PHP script, you need to be
>>> able to connect to the server.
>>
>>>> I don't think there's a problem accessing the file.  It's just that it
>>>> doesn't display anything on my browser.
>>
>>>> Thanks,
>>>> Peter.
>>
>>> It won't, if you aren't accessing it through a web server (or the most
>>> it would display is the source code for your script).
>>
>>> To get it to work, you MUST have a running web server and be able to
>>> connect to that web server.
>>
>> ...which means you have to set up apache's configuration file.  I get
>> the idea that the OP has installed WAMP but hasn't configured apache,
>> or maybe hasn't set up the hosts file, or maybe both.
>>
>> Peter: Have you edited apache's configuration file "httpd.conf"?
>> There's a menu item for that, left-click the WAMP taskbar icon, select
>> Apache, select httpd.conf; unless you at least modify the DocumentRoot
>> specification, it'll never find your localhost's root document
>> directory.
>
> Actually that's another problem I have with the WAMP I downloaded from
> wampserver.com. I double (left) click

Double-click is not the same as left-click. It takes different
actions for each.

> on the wampmanager icon on the
> desktop and nothing happens. However I opened httpd.conf with NotePad
> and saw DocumentRoot specified by
> DocumentRoot "c:/wamp/www/"

I'm not sure where it is if you don't set it where you want it.

> Is the root document the Desktop virtual folder which contains the My
> Documents, My Computer, My Network Places and Recycle Bin virtual
> folders? Thanks.

I'm not sure what you're asking there. You probably need to look
through httpd.conf in some detail.

>>
>> For apache-specific stuff (like configuration details), you probably
>> ought to go to alt.apache.configuration
>
> Thanks. I've checked that out. Thank you so much for your help.

Best luck having fun with it. <g>

--
no aluminum siding offers today
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173392 is a reply to message #173388] Thu, 07 April 2011 09:28 Go to previous messageGo to next message
crankypuss is currently offline  crankypuss
Messages: 147
Registered: March 2011
Karma: 0
Senior Member
Peter Lauren <peterdlauren(at)gmail(dot)com> wrote:

> On Apr 6, 5:21 pm, "Mr. B-o-B" <mr.chew.b...@gmail.com> wrote:
>> Peter Lauren cried from the depths of the abyss...
>>
>>> I double (left) click on the wampmanager icon on the
>>> desktop and nothing happens.
>>
>> Don't double click.  Just *single* left click the icon for the prize.
>>
>> Mr. B-o-B
>
> Hi Mr. Bob, Well I'm out of the abyss now because I finally have PHP
> code running on my browser (through the server). Unfortunately, the
> single click worketh not for the wampmanager icon. Seems I don;t need
> it anyway.

Well, maybe you don't, but maybe you do. If you can't click on the
*taskbar* icon with the left and right buttons, and get two different
menus, something is probably not quite right. The right-click menu
isn't that useful but it does have an Exit function. The left-click
menu has a number of useful functions like stop/start/restart
services, offline/online, apache/php/mysql and suchlike.

--
no aluminum siding offers today
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173394 is a reply to message #173385] Thu, 07 April 2011 13:16 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On Wed, 06 Apr 2011 20:19:00 -0700, Peter Lauren wrote:

> On Apr 4, 1:19 pm, Denis McMahon <denis.m.f.mcma...@gmail.com> wrote:
>> On Sun, 03 Apr 2011 04:54:02 -0700, Peter Lauren wrote:
>>> I am using Windows XP have installed WAMP and PHP as outlined here
>>> http://www.wampserver.com/en/........ [deleted]
>>
>> Simplified explanation for how php works on a webserver:
>>
>> 1) A surfer users their web browser to send a request to a webserver at
>> "http://<host>/<path>/<file>"
>>
>> ("<file>" is usually somename.php)
>>
>> 2) The webserver at "<host>" determines what file in it's filesystem
>> "<path>/<file>" refers to.
>>
>> 3) The webserver at "<host>" determines that the file in it's
>> filesystem that "<path>/<file>" refers to should be parsed for php code
>> before sending it to the surfers browser.
>>
>> 4) The webserver at "<host>" sends the actual file that "<path>/<file>"
>> refers to to the php script processor, and then sends the output from
>> the php script processor back to the web browser.
>>
>> You need to check that your web server is working. If it's on the same
>> machine as you are developing code on, try using your web browser to
>> connect to:
>>
>> a)http://localhost/
>>
>> or
>>
>> b)http://127.0.0.1/
>>
>> (If it is some other machine, modify the (a) host name or (b) ip
>> address as appropriate)
>>
>> If your web server is working, you should get a default page announcing
>> itself as apache (as you have installed wamp).
>>
>> If you don't get a "welcome to apache webserver" page, then you need to
>> start the webserver. That is beyond the scope of my knowledge, try
>> googling "wamp start webserver process"
>>
>> Once the web server is working, you next need to locate where the
>> webserver root is. This is not the root of your hard disc (or it damn
>> well shouldn't be) and will be specified in a configuration file.
>> Again, google is your friend.
>>
>> In the document root, insert a file called phpinfo.php with the text
>> between the cutlines below:
>>
>> ---8<--- cut here ---8<---
>> <?php phpinfo(); ?>
>> ---8<--- cut here ---8<---
>>
>> Then connect to the following url:
>>
>> http://<(a) server host name or (b) server ip address>/phpinfo.php
>>
>> And if you have been successful, and the web server is running, and
>> your configuration is correct, you will get displayed on your screen a
>> large amount of information about the php and web server configuration.
>>
>> Rgds
>>
>> Denis McMahon
>
> Hi Denis,
>
> On Win XP I went to Start:Run and ran net start wampapache
>
> When I go to http://localhost/, I get a page with the wampserver icon
> and a bunch of stuff including the following.
>
> Server Configuration
>
> Apache Version :
> 2.2.17
> PHP Version :
> 5.3.5
> Loaded Extensions :
>
> * Core
> * bcmath
> * calendar
> [and several other extensions]
>
> MySQL Version :
> 5.5.8
> ---------------------------------------------------------------
>
> The httpd.conf file gives DocumentRoot "c:/wamp/www/"
>
> However when I just have <a href="index.php">PHP</a> on my web page, I
> get a message that it cannot find the file because it is looking in the
> folder that contains the html file. When I use <a
> href="c:/wamp/www/index.php">PHP</a> I get an alert message "Firefox
> doesn't know how to open this address, because the protocol (c) isn't
> associated with any program"
>
> Thanks,
> Peter.


1) If the php file doesn't exist, then of course your web server will
give an error message 404 if it is asked for it.

2) You must use url style addressing in href="" in your web documents,
not operating system based file paths.

3) The file that I suggested you create was:

>> In the document root, insert a file called phpinfo.php with the text
>> between the cutlines below:
>>
>> ---8<--- cut here ---8<---
>> <?php phpinfo(); ?>
>> ---8<--- cut here ---8<---
>>
>> Then connect to the following url:
>>
>> http://<(a) server host name or (b) server ip address>/phpinfo.php

So:

1) create a file in eg notepad that just contains the following as a
single line of text:

<?php phpinfo(); ?>

2) save it in directory "c:\wamp\www\" as filename "phpinfo.php"

3) access it in your web browser as "http://localhost/phpinfo.php"

Now, if you want a file called "index.php" you have to create that file
in the directory "c:\wamp\www" and it should probably contain php script
commands.

Rgds

Denis McMahon
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173395 is a reply to message #173385] Thu, 07 April 2011 14:09 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On Wed, 06 Apr 2011 20:19:00 -0700, Peter Lauren wrote:

> The httpd.conf file gives DocumentRoot "c:/wamp/www/"

The following is something you ABSOLUTELY MUST understand:

DocumentRoot is a definition for the software running on your machine and
is relative to your local file system.

internet www urls know EXACTLY NOTHING about the filesystem of the
machine that is running any given webserver

File name "fred.type" in the directory defined by "DocumentRoot" on the
machine at ip address "a.b.c.d" is referenced with the url: "http//
a.b.c.d/fred.type"

If the machine also has a dns entry that maps name "webserver" to ip
address "a.b.c.d", then the file can also be referenced with the url
"http//webserver/fred.type"

the dns name "localhost" is a special dns name for the special ip address
"127.0.0.1" which means "the same machine as I am", this means that if
your web server is running on the same machine that you are using a web
browser on, you can look at html file "filename.htm" or php file
"filename.php" in the DocumentRoot" by using the urls "http://localhost/
filename.htm" and "http://localhost/filename.php" respectively in the
address bar of your browser.

Note, however, that you REALLY REALLY SHOULD NOT use "localhost" or
"127.0.0.1" in any url inside a file in the "DocumentRoot" directory or
it's sub directories, as the special dns entry and special ip address
will ONLY WORK if you are using a browser on the SAME MACHINE as the
webserver.

So, for example if you want to include a link to the file at "c:\wamp\www
\index.php" inside the file "c:\wamp\www\index.htm" so that you link from
the htm file to the php file when DocumentRoot is "c:\wamp\www", your
link inside the htm file would look something like:

<a href="index.php">link text</a>

And when you access the file "http://localhost/index.htm" and clink on
the link "link text" it should then jump to the output of the php script
"index.php".

Of course, "index.php" needs some php code inside it for this to work.
Try the following line for a start:

<?php echo "<p>Hello, This is php</p>"; ?>

Here endeth the lesson. If you have not now managed to get your server
displaying php files correctly, then either (a) your configuration is
broken, (b) your installation is broken, (c) I screwed up the
instructions, or (d) you're not following the instructions correctly.

If (c) is the case, I'm sure several people will tell us both!

Rgds

Denis McMahon
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173399 is a reply to message #173392] Fri, 08 April 2011 02:53 Go to previous messageGo to next message
Peter Lauren is currently offline  Peter Lauren
Messages: 48
Registered: April 2011
Karma: 0
Member
On Apr 7, 5:28 am, crankypuss <n...@email.thanks> wrote:
> Peter Lauren <peterdlau...@gmail.com> wrote:
>> On Apr 6, 5:21 pm, "Mr. B-o-B" <mr.chew.b...@gmail.com> wrote:
>>> Peter Lauren cried from the depths of the abyss...
>
>>>> I double (left) click on the wampmanager icon on the
>>>> desktop and nothing happens.
>
>>> Don't double click.  Just *single* left click the icon for the prize..
>
>>> Mr. B-o-B
>
>> Hi Mr. Bob,  Well I'm out of the abyss now because I finally have PHP
>> code running on my browser (through the server).  Unfortunately, the
>> single click worketh not for the wampmanager icon.  Seems I don;t need
>> it anyway.  
>
> Well, maybe you don't, but maybe you do.  If you can't click on the
> *taskbar* icon with the left and right buttons, and get two different
> menus, something is probably not quite right.  The right-click menu
> isn't that useful but it does have an Exit function.  The left-click
> menu has a number of useful functions like stop/start/restart
> services, offline/online, apache/php/mysql and suchlike.

I just noticed that I do have the Wampserver icon on the quick launch
part of the task bar. I do actually get one menu, with the function
you mention, with a a single click of the left button and a smaller
menu, with the Exit function, with a single click of the right. So it
looks like I'm in business.

Thanks,
Peter.
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173400 is a reply to message #173399] Fri, 08 April 2011 12:04 Go to previous messageGo to next message
Mr. B-o-B is currently offline  Mr. B-o-B
Messages: 42
Registered: April 2011
Karma: 0
Member
Peter Lauren cried from the depths of the abyss...

> I just noticed that I do have the Wampserver icon on the quick launch
> part of the task bar. I do actually get one menu, with the function
> you mention, with a a single click of the left button and a smaller
> menu, with the Exit function, with a single click of the right. So it
> looks like I'm in business.

Fantastic.
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173405 is a reply to message #173395] Fri, 08 April 2011 17:33 Go to previous messageGo to next message
Peter Lauren is currently offline  Peter Lauren
Messages: 48
Registered: April 2011
Karma: 0
Member
On Apr 7, 10:09 am, Denis McMahon <denis.m.f.mcma...@gmail.com> wrote:
> Note, however, that you REALLY REALLY SHOULD NOT use "localhost" or
> "127.0.0.1" in any url inside a file in the "DocumentRoot" directory or
> it's sub directories, as the special dns entry and special ip address
> will ONLY WORK if you are using a browser on the SAME MACHINE as the
> webserver.
>
> So, for example if you want to include a link to the file at "c:\wamp\www
> \index.php" inside the file "c:\wamp\www\index.htm" so that you link from
> the htm file to the php file when DocumentRoot is "c:\wamp\www", your
> link inside the htm file would look something like:
>
> <a href="index.php">link text</a>
>

That's where I have a problem. If I use <a href="index.php">link
text</a> instead of <a href="http://localhost/Examples.php">link
text</a>, it looks for the file in the directory where the html file
is located instead of in the "DocumentRoot" directory.

Thanks,
Peter.
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173406 is a reply to message #173395] Fri, 08 April 2011 17:34 Go to previous messageGo to next message
Peter Lauren is currently offline  Peter Lauren
Messages: 48
Registered: April 2011
Karma: 0
Member
On Apr 7, 10:09 am, Denis McMahon <denis.m.f.mcma...@gmail.com> wrote:
> Note, however, that you REALLY REALLY SHOULD NOT use "localhost" or
> "127.0.0.1" in any url inside a file in the "DocumentRoot" directory or
> it's sub directories, as the special dns entry and special ip address
> will ONLY WORK if you are using a browser on the SAME MACHINE as the
> webserver.
>
> So, for example if you want to include a link to the file at "c:\wamp\www
> \index.php" inside the file "c:\wamp\www\index.htm" so that you link from
> the htm file to the php file when DocumentRoot is "c:\wamp\www", your
> link inside the htm file would look something like:
>
> <a href="index.php">link text</a>
>

That's where I have a problem. If I use <a href="index.php">link
text</a> instead of <a href="http://localhost/Examples.php">link
text</a>, it looks for the file in the directory where the html file
is located instead of in the "DocumentRoot" directory.

Thanks,
Peter.
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173407 is a reply to message #173400] Fri, 08 April 2011 17:45 Go to previous messageGo to next message
Peter Lauren is currently offline  Peter Lauren
Messages: 48
Registered: April 2011
Karma: 0
Member
On Apr 8, 8:04 am, "Mr. B-o-B" <mr.chew.b...@gmail.com> wrote:
> Peter Lauren cried from the depths of the abyss...
>
>> I just noticed that I do have the Wampserver icon on the quick launch
>> part of the task bar.  I do actually get one menu, with the function
>> you mention, with a a single click of the left button and a smaller
>> menu, with the Exit function, with a single click of the right.  So it
>> looks like I'm in business.
>
> Fantastic.

Thanks. But I'm still having a problem. I left-click on the task bar
icon, click on Apache:httpd.conf, and a file opens in notepad. In
admin. mode, I can edit the file and set
DocumentRoot "f:/SomeOther/Directory"
It still uses the .php file in c:\wamp\www

Thanks,
Peter.
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173408 is a reply to message #173395] Fri, 08 April 2011 17:53 Go to previous messageGo to next message
Peter Lauren is currently offline  Peter Lauren
Messages: 48
Registered: April 2011
Karma: 0
Member
On Apr 7, 10:09 am, Denis McMahon <denis.m.f.mcma...@gmail.com> wrote:

> Note, however, that you REALLY REALLY SHOULD NOT use "localhost" or
> "127.0.0.1" in any url inside a file in the "DocumentRoot" directory or
> it's sub directories, as the special dns entry and special ip address
> will ONLY WORK if you are using a browser on the SAME MACHINE as the
> webserver.

> So, for example if you want to include a link to the file at "c:\wamp\www
> \index.php" inside the file "c:\wamp\www\index.htm" so that you link from
> the htm file to the php file when DocumentRoot is "c:\wamp\www", your
> link inside the htm file would look something like:

> <a href="index.php">link text</a>

That's where I have a problem. If I use <a href="index.php">link
text</a> instead of <a href="http://localhost/Examples.php">link
text</a>, it looks for the file in the directory where the html file
is located instead of in the "DocumentRoot" directory.

Also, the URL box shows the location as
file:///F:/Directory/With/Html/File/Examples.php

Thanks,
Peter.
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173410 is a reply to message #173405] Fri, 08 April 2011 18:00 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 4/8/2011 1:33 PM, Peter Lauren wrote:
> On Apr 7, 10:09 am, Denis McMahon<denis.m.f.mcma...@gmail.com> wrote:
>> Note, however, that you REALLY REALLY SHOULD NOT use "localhost" or
>> "127.0.0.1" in any url inside a file in the "DocumentRoot" directory or
>> it's sub directories, as the special dns entry and special ip address
>> will ONLY WORK if you are using a browser on the SAME MACHINE as the
>> webserver.
>>
>> So, for example if you want to include a link to the file at "c:\wamp\www
>> \index.php" inside the file "c:\wamp\www\index.htm" so that you link from
>> the htm file to the php file when DocumentRoot is "c:\wamp\www", your
>> link inside the htm file would look something like:
>>
>> <a href="index.php">link text</a>
>>
>
> That's where I have a problem. If I use<a href="index.php">link
> text</a> instead of<a href="http://localhost/Examples.php">link
> text</a>, it looks for the file in the directory where the html file
> is located instead of in the "DocumentRoot" directory.
>
> Thanks,
> Peter.

Which is where it's supposed to look (relative to the script being
executed). If you want it from the document root, you need to specify
to use the document root, i.e. <a href="http::/index.php">

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173411 is a reply to message #173407] Fri, 08 April 2011 18:01 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 4/8/2011 1:45 PM, Peter Lauren wrote:
> On Apr 8, 8:04 am, "Mr. B-o-B"<mr.chew.b...@gmail.com> wrote:
>> Peter Lauren cried from the depths of the abyss...
>>
>>> I just noticed that I do have the Wampserver icon on the quick launch
>>> part of the task bar. I do actually get one menu, with the function
>>> you mention, with a a single click of the left button and a smaller
>>> menu, with the Exit function, with a single click of the right. So it
>>> looks like I'm in business.
>>
>> Fantastic.
>
> Thanks. But I'm still having a problem. I left-click on the task bar
> icon, click on Apache:httpd.conf, and a file opens in notepad. In
> admin. mode, I can edit the file and set
> DocumentRoot "f:/SomeOther/Directory"
> It still uses the .php file in c:\wamp\www
>
> Thanks,
> Peter.

Did you stop and restart Apache after making the changes? The
configuration file is only run when Apache starts up, not on every request.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173412 is a reply to message #173406] Fri, 08 April 2011 18:17 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On Fri, 08 Apr 2011 10:34:12 -0700, Peter Lauren wrote:

> On Apr 7, 10:09 am, Denis McMahon <denis.m.f.mcma...@gmail.com> wrote:
>> Note, however, that you REALLY REALLY SHOULD NOT use "localhost" or
>> "127.0.0.1" in any url inside a file in the "DocumentRoot" directory or
>> it's sub directories, as the special dns entry and special ip address
>> will ONLY WORK if you are using a browser on the SAME MACHINE as the
>> webserver.
>>
>> So, for example if you want to include a link to the file at
>> "c:\wamp\www \index.php" inside the file "c:\wamp\www\index.htm" so
>> that you link from the htm file to the php file when DocumentRoot is
>> "c:\wamp\www", your link inside the htm file would look something like:

>> <a href="index.php">link text</a>

> That's where I have a problem. If I use <a href="index.php">link
> text</a> instead of <a href="http://localhost/Examples.php">link
> text</a>, it looks for the file in the directory where the html file is
> located instead of in the "DocumentRoot" directory.

Where do you expect it to look?

URLs can be shortened in many ways, when a URL is shortened browsers will
try and make sense of them, and servers will try and interpret what the
browser offers them, but if your browser asks a server for a file it
can't find, you'll get an error (which the browser may hide from you
while it tries something else)

You're obviously having problems understanding how urls relate to files
and servers.

A url such as "http://server/path/file.type" generally means go to the
web server "server" and ask it for "/path/file.type"

In the absence of anything that tells it otherwise in the configuration
file "/path/" usually maps in some fairly literal way to the directory
structure below whatever is configured as DocumentRoot, eg on your
windows machine, where DocumentRoot is (I think) "c:\wamp\www\", then if
"/path/" in the url was "/fred/jim/tony/" your server would be looking in
"c:\wamp\www\fred\jim\tony\" for a file called "file.type", which it
would then process according to any other instructions (such as things
that tell it what to do with ".php" files etc)

Now, a url may get shortened, to, for example "file.type", in which case,
when a browser requests "file.type" because a user has clicked on a link,
the browser will use the path information of the current file to build
the request.

This means that if you're looking at "http://server/joe/sue/file1.type1"
and click a link that was coded as '<a href="file2.type2">some text</a>'
then the web browser logic works something like:

I'm looking at "http://server/joe/sue/file1.type1" and now I want
"file2.type2" so I request "http://server/joe/sue/file2.type2"

and you would expect your server to deliver c:\wamp\www\joe\sue
\file2.type2

However, if the link was '<a href="/file2.type2">some text</a>', the
browser logic works something like:

I'm looking at http://server/joe/sue/file1.type1 and now I want "/
file2.type2" so I request "http://server/file2.type2"

and you would expect your server to deliver c:\wamp\www\file2.type2

The leading slash means "start at the webroot and work down"

There are other ways links can be specified:

".." means "up one directory level"

With '<a href="../alison/file2.type2">some text</a>' the browser logic
works something like:

I'm looking at "http://server/joe/sue/file1.type1" and now I want
"../alison/file2.type2" so I request "http://server/joe/alison/
file2.type2"

and you would expect your server to deliver c:\wamp\www\joe\alison
\file2.type2

and with '<a href="../file2.type2">some text</a>' the browser logic works
something like:

I'm looking at "http://server/joe/sue/file1.type1" and now I want
"../file2.type2" so I request "http://server/joe/file2.type2"

and you would expect your server to deliver c:\wamp\www\joe\file2.type2

Finally, a note of caution. If you use "localhost" or "127.0.0.1" as the
"server" in the urls in web pages on your computer, anyone trying to view
the web pages from from any other computer WILL get errors. If you wish
to specify absolute paths from the webroot, use

'href="http:/path/file.type"'

and not

'href="http://localhost/path/file.type"'

This is because when their web browser process "localhost" or "127.0.01",
it will try and ask a webserver running on their machine for the file
(because on their machine, localhost is their machine) and obviously,
even if they have a webserver running, it won't be using the files from
the DocumentRoot c:\wamp\www on your machine.

This really is outside the scope of comp.lang.php though.

I'm setting followups to comp.infosystems.www.authoring.html

Rgds

Denis McMahon
Re: PHP Runs In WinXP Command Window But Not In Browser [message #173413 is a reply to message #173408] Fri, 08 April 2011 18:30 Go to previous messageGo to previous message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On Fri, 08 Apr 2011 10:53:34 -0700, Peter Lauren wrote:

> Also, the URL box shows the location as
> file:///F:/Directory/With/Html/File/Examples.php

You seem to be opening a local php file directly in the web browser. I'm
sure this has already been discussed in the thread.

1) Put it somewhere the web server knows about it
2) Access it by telling the browser to request it from the web server
instead of from the filesystem

Rgds

Denis McMahon
Pages (4): [1  2  3  4    »]  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: neither var_dump() nor die() displays anything
Next Topic: Spaces in filenames
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 09 00:58:18 GMT 2024

Total time taken to generate the page: 0.03212 seconds