Jump to content


Photo

viewing todaysdate.php


  • Please log in to reply
3 replies to this topic

#1 Doug.Gentry

Doug.Gentry
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 04 June 2006 - 06:27 PM

I following along in this book named Apache,Mysql and PHP Web Development for Dummies.

I followed and wrote out the code for viewing todays date .
I saved it as todaysdate.php in a directory named phpfiles.

when I go to that directoy and double click on the todaysdate.php it wants to open it with gedit.
if I change the name to todaysdate.html it will open in firefox but not show the date or do what it's suppoed to do.
I'm used to being able to open an html file in the editor and change it, save and refreash the webpage and see the changes.

how does one do this with a .php file?
Here's the php file in case that helps.
More than likly I just need to go back a few chapters and re-read something hu?

<html>
<head>
<title>Today's Date</Title>
</head>
<body>
Greetings! Today is
<?php
$today = getdate();
$month = $today['month'];
$mday = $today['mday'];
$year = $today['year'];
print=" $month $mday, $myear\n";
?>
</body>
</html>

I saved it as todaysdate.php


#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 04 June 2006 - 06:33 PM

you need to install apache and php on your computer and have the php file in a directory that it points to
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 04 June 2006 - 06:36 PM

You cannot execute PHP files the way you do with HTML files, ie double click it and it'll open up in the browser. As PHP is a server-side lanaguage it requires a server that is configured to execute any .php files with the PHP intepreter. Now in order to do this you need to open up a browser and type in [a href=\"http://localhost/\" target=\"_blank\"]http://localhost/[/a] you should see list of files and folders now click the file you want to execute, or typeing the actuall name of the script like so: [a href=\"http://localhost/todaysdate.php\" target=\"_blank\"]http://localhost/todaysdate.php[/a]

NOTE: the url [a href=\"http://localhost/\" target=\"_blank\"]http://localhost/[/a] will only work if you have a server setup on your computer. Now with the Dummies book you have there should be chapter or an apendix section that tells you how to setup a server on your computer.

#4 Doug.Gentry

Doug.Gentry
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 04 June 2006 - 07:44 PM

[!--quoteo(post=379988:date=Jun 4 2006, 11:36 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Jun 4 2006, 11:36 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
You cannot execute PHP files the way you do with HTML files, ie double click it and it'll open up in the browser. As PHP is a server-side lanaguage it requires a server that is configured to execute any .php files with the PHP intepreter. Now in order to do this you need to open up a browser and type in [a href=\"http://localhost/\" target=\"_blank\"]http://localhost/[/a] you should see list of files and folders now click the file you want to execute, or typeing the actuall name of the script like so: [a href=\"http://localhost/todaysdate.php\" target=\"_blank\"]http://localhost/todaysdate.php[/a]

NOTE: the url [a href=\"http://localhost/\" target=\"_blank\"]http://localhost/[/a] will only work if you have a server setup on your computer. Now with the Dummies book you have there should be chapter or an apendix section that tells you how to setup a server on your computer.
[/quote]

Ah, that makes sense. I do have Apache set up on here and Mysql.
Now I remember a section where your php files need to in a certain location. DOH!

thanks
Doug





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users