| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
|
|
#22 (permalink) |
|
with a hint of lemon
Join Date: Aug 2006
Location: Sheffield
Posts: 489
|
yerp that all of it... Online portfolio: mgpwr.co.uk
|
|
|
|
#24 (permalink) |
|
with a hint of lemon
Join Date: Aug 2006
Location: Sheffield
Posts: 489
|
Fatal error: Call to undefined function: array() in mgpwr.co.uk/greeting.php on line 6 you try it on yours, cos i'm stumped! Online portfolio: mgpwr.co.uk
|
|
|
|
#25 (permalink) |
|
Senior Member
Join Date: Jan 2005
Posts: 12,340
|
echo $message(date("G")); Should be... echo $message[date("G")]; That's the only problem I had when I ran it on my dev box. Even with error reporting set to E_ALL. If that doesn't work, you've made a mistake - left out a quote or a comma or a bracket or something somewhere. Or try capitalizing the word Array (I often see it used that way). |
|
|
|
#29 (permalink) |
|
with a hint of lemon
Join Date: Aug 2006
Location: Sheffield
Posts: 489
|
Yup, its working, thanks.. Online portfolio: mgpwr.co.uk
|
|
|
|
#30 (permalink) | |
|
with a hint of lemon
Join Date: Aug 2006
Location: Sheffield
Posts: 489
|
Quote:
I have added this just above the script i am using to say the quotes depending on the time, how will i know if it is working, i have changed the time zone on my laptop and it still stays with the same message.. so err how would i test it is working? Online portfolio: mgpwr.co.uk
|
|
|
|
|
#31 (permalink) |
|
shiro
Join Date: Aug 2007
Location: Yokohama, Japan
Posts: 2,610
|
Add a link to a page that outputs the time and get some of us to check it for you. We are in many different timezones. I tried by checking myself in my timezone, and having my buddy in the states check in his. We were both in different timezones that the server, and both were correct. But truth be told, that was the extent of my checking, so there is the possibility that the script is flawed and that it doesn't work! |
|
|
|
#32 (permalink) |
|
trouble free and loverlee
Join Date: Mar 2003
Location: YooKay
Posts: 2,933
|
Imho™… For such a non-critical thing, javascript would be the better option. Its date functions work according to the date on the user's machine. So, presuming the date on their machine is set correctly, it'll automatically be a localised time-based greeting. JavaScript Date Object Reference You could have a default greeting in the markup and use js to customise it to a localised, time-based greeting. (rough) e.g. Code:
Code:
|
|
|
|
#33 (permalink) |
|
with a hint of lemon
Join Date: Aug 2006
Location: Sheffield
Posts: 489
|
yerp, the page i have used it on is: Mgpwr.co.uk | .Welcome | Mark Petherbridge, Sheffield, Yorkshire based freelance website and graphic designer go a head and check, thank you Online portfolio: mgpwr.co.uk
|
|
|
|
#34 (permalink) |
|
shiro
Join Date: Aug 2007
Location: Yokohama, Japan
Posts: 2,610
|
Well, whatever you have done, it didn't work, as the greeting is telling me good morning, but it is evening where I am. Actually Bill Posters is entirely correct in what he is saying. His code is much less bulky and easier to use than what I posted. What I forgot until I read his post is that I created that code to show all times, not just the current time, in the user's timezone (for example times on posts on a forum). Since you can't get the code I gave you to work, I would suggest adding his code to your site, as it should work as is. |
|
|
|
#36 (permalink) |
|
Everything is fine.
|
I definitely agree with Bill. Since you were going using use JavaScript with your PHP code to retrieve the users timezone for the calculation, you may as well use an entire JavaScript solution instead. Instead of using the old 'document.write' method, Bill has given the best solution using the DOM to produce the greeting. This also provides a decent fall back if the user has JavaScript turned off; the visitor will simply see the original 'Welcome' message as opposed to the customized greeting which is better than displaying an incorrect time message, or worse case scenario, nothing at all. Just my 2 cents - Mike |
|
![]() |