FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Simple PHP script not working





Solugon
My PHP script is really, REALLY simple. I took it from the book I'm using to learn PHP, so you'd think it would work.

Code:

<?php print(Date("l F d, y")); ?>


Although, looking back at the code, there's another version where the "f" is lowercase....
Kaneda
Absolutely nothing wrong with it that I can see. Although I tend to write PHP functions in lowercase ("date()" rather than "Date()"), PHP is only halfways case sensitive (variables are case sensitive, functions aren't), so nothing wrong there. The date formatting string is correct (it would output something like "Saturday March 04, 2006".

What error do you get?
Solugon
No error whatsoever. It just doesnt show anything.

Go to phptest.frontlines.frih.net if you want to see what I mean. I'm sure you know how to view the page source if you need to look over the code.
n0obie4life
Code:
<?php

echo date("l F d, y");

?>


I don't like print Smile
Solugon
Still not working.
Kaneda
n0obie4life wrote:
Code:
<?php

echo date("l F d, y");

?>


I don't like print Smile


Nah, neither do I, but it's not wrong (and there's nothing really wrong with print as compared to echo other than it being mostly useless and a teeny weeny bit slower).

Looked at the HTML source of that page, Solugon, and the problem seems to be that the PHP isn't handled by the server at all Wink The page is just spewed out without any processing by PHP. Which is probably (I don't know the setup of the Frihost servers) because your file is called "index.html", not "index.php".

In short, try renaming the file to "index.php" Wink
Solugon
Ahh. Razz Well, maybe this would be a good time to ask what the .phtml extension is for?

Edit: It's working now. Yay!
Kaneda
Solugon wrote:
Ahh. Razz Well, maybe this would be a good time to ask what the .phtml extension is for?

Edit: It's working now. Yay!


.phtml and .php3 are old extensions used to signify to the server that it should send the files through the PHP preprocessor. In order to not consume resources on static html, normally the server is not setup to preprocess files with the .html extension. These days, most people simply use .php, rather than .phtml or .php3 (which, as the name implies, was mainly in use for PHP version 3 Wink).

Glad it worked Smile
Related topics
[tutor] How to protect images without htaccess using PHP
Simple PHP Navigation
Running a "Hello World" php script
I need a VERY simple php script
another simple php request
Preventing bad PHP script calls
30frih for a php rotator script
VERY simple php script needed
How to get a php script working under a cron job?
PHP script to create email addresses/ftp accounts/etc...
How to build simple PHP upload form
php script for Changing file permissions & owner
need help in a simple php register script based on flat file
[Help] php script to post to twitter
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.