Page 1 of 1

Running My First PHP Script

Posted: Sat Jun 17, 2006 6:47 pm
by aawood
Hello All

Apologies for posting something so simple but i can't get my first PHP script to work and i was wondering if anyone could help me out.

I'm working from Sams Teach Yourself PHP, MySQL and Apache

I have just installed:
MySql 4.0.21
Apache 2.0.52
PHP5.0
& Zend Studio

The book tells you to write your first script and then test it in your web browser.

The script is as follows:
<?php
echo "Hello Web!";
?>

Are you meant to save the file in a certain place?

When typing http://localhost/first.php i should get Hello Web but i get page can't be found.

Please tell me where i'm being a plumb.

Regards

aawood

Posted: Sat Jun 17, 2006 8:10 pm
by Benjamin
What is the current full path to first.php?

Re: Running My First PHP Script

Posted: Sat Jun 17, 2006 10:28 pm
by ambivalent
aawood wrote:Are you meant to save the file in a certain place?
If I recall correctly, the location to store your files is c:\program files\apache\htdocs *or something similar* (do a CTRL + F for htdocs)

You can test your apache installation by pointing your browser at http://localhost OR http://127.0.0.1 -> it should spit out apache's default/test page.

Once you know where to save your files, create a new php file as follows:

Code: Select all

<?php

phpinfo();

?>
Assuming everything is installed and working as it should, this will spew forth a great deal of information with respect to the configuration of your php installation.

Posted: Mon Jun 19, 2006 12:05 pm
by aawood
Excellent guys. The book didn't tell me to save the file to c:\program files\apache\htdocs. I've now saved the file there and tested it and it all works now.

Thanx very much for all your help.

Posted: Mon Jun 19, 2006 1:15 pm
by Luke
That's the first book I bought when I was learning PHP. I thought it was pretty good. It's been so long since then though... man!

Posted: Tue Jun 20, 2006 12:13 am
by technofreak
As far as i have come through, the books for PHP doesn't point out where the readers should save their .php files, in order to get the page when accessed in the browser by typing "http://localhost/filename.php". When I started working in PHP, I also faced the same problem. Thankgod, I had friends who were working with PHP that they told me the answer.

I use Learning PHP5 from O'Reilly and PHP.net online manual. In addition to these books, effective use of online forums like devnetworks will be enough for a newbie to learn PHP fast and efficiently.

The fact to be remembered is "Learning is directly proporational to Practical Working" The more the code you write yourselves and practice, the more you learn. :)

Posted: Wed Jun 21, 2006 3:10 pm
by aawood
Thanx for all your help guys. I'm so glad i found this forum. AS you all said i just need to follow the bok and keep writing code. Hopefully i will then get the website i want to build up and runing.