I was playing around with the php coding that allows a page to bring up the date and time from your web server. I was not able to get it to work. Help???
This is the code used:
<?php
echo date(‘1, F dS Y.’)’
?>
Is this correct?
Also, not sure if php is active on my web server. It has been installed. Just need some help with php.
You’re pretty close. Take a look at http://php.net/manual/en/function.date.php when you get a chance and you’ll see the different date parameters you can use. By changing the values within the parentheses you’ll change the way the date is formatted.
<?php
$date = date("m/d/Y");
echo("$date");
?>
This will output 02/10/2010 (assuming that today is really the 10th). If you used a lowercase y instead it would output 02/10/10. You can change these parameter values and experiment how you’d like your date to appear.
You may also need to set your timezone. If you can’t change the server timezone you can always set it with PHP.
Not sure but that didn’t work either. Perhaps there is something that I am not doing or doing. PHP 5.3.1 is running on my web server. However, when I run the code on the web server nothing happens within a html file. What am I doing wrong? HELP
Have you named your file .php?
If you place phpinfo(); in your PHP file what do you see?
Does the file have the appropriate permissions set? (Needs view access)
If you’re trying this in a page with existing code then instead try creating a blank PHP file and pasting the code in there. This will remove any chance that the other code is horking things up.
Forget about the permissions if you’re running Windows. The file system has permissions but you’re most likely okay. I was assuming you were running Linux. I should never ever assume…
So when you pull up the time.php file in your browser it’s completely blank? Try pasting this into your PHP file and let me know if you see a big long screen telling you all about your PHP installation:
Bugger. That means you’ve got larger problems. Essentially your code isn’t being passed through the PHP engine (probably wrong terminology) before being sent to the browser so you’re not seeing any cool PHP functions.
I assumed once and was wrong so I’m going to go try and ask everything. Are you administrating this server yourself? If not, it sounds like you need to go back to the server administrator and find out why PHP isn’t running for your server.
If this is a local server that you’re just trying to get setup then it’s time to go back to your PHP installation and configuration. Something went wrong there and needs to be fixed.
The servers are all mine, I am the administrator with full security and permissions. Server has been operating and active for 5 years.
I decide to attempt to add some enhancements with php and here we are. Php is not new to me and I to it, I would say that something with the configuration is the issue.
It will not run no php cool things. Either the version or configuration, so back to the drawing board.
Oye. Well, Willie, at least it sounds like you know your way around your servers. Could be worse.
Gotta be something with the configuration. If all else fails, check to make sure that the services are started. I know all the “experts” get cranky when I suggest that they make sure the computer is plugged in before trying to turn it on but I’m always surprised at how often that fixes the problem.
That article seems to be pretty comprehensive in terms of installing PHP on Windows 2003. It appears that there’s actually no service for PHP. Oops. I’m trying to remember years ago when I was running a local installation and I must have been thinking about the Apache service. Sorry.
Both of those sites are pretty good as well if you’re still having trouble. If you had it working before, I would go back and ask what you changed? If it worked before and doesn’t work now it would stand to reason that whatever you changed broke it.
Sorry, wish I could be more help in this department but servers aren’t my thing. I just write code.
This might be a good post in the Server Management forum. The folks over there are pretty smart and they can probably help you a lot more than I can.
We have smart folks here too.
how do you “run” this file? by clicking it in explorer window or by querying it in the browser?
What do you see in the browser’s address bar? there must be something like http://localhost/yourfile.php
Do you have web server installed?
is there PHP installed?
Hey Jeff.
About code you write.
There was nothing wrong with Willie’s very first code and you made it bad.
echo(“$date”);
Brackets are unnecessary here and quotes are just wrong.
When you address a variable, never use quotes. Or you’ll have an error someday.
That’s simple:
echo $var not echo "$var";
some_function($var) not some_function("$var");
Thanks for looking in. I am attempting to run php on my present Web server which is a Window 2003 server that is a .net and web files are .aspx. I have installed php 5.3.1 and MySQL in an attempt to setup a php/mysql database. At this point just trying to get php to talk to mysql is an issue. I just not one for open source appls. If you could help it would deeply appreciated.