glow Posted October 29, 2014 Share Posted October 29, 2014 (edited) Hi I'm in need of help with some errors that the admin page of my cms is spitting out, I'm very new to php but I'm great understanding directions so any help that anyone can provide will be greatly appreciated. These are the errors being displayed: Warning: date() [function.date]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Chicago' for 'CDT/-5.0/DST' instead in /home/mysite/public_html/includes/joomla.php on line 437 Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/mysite/public_html/includes/joomla.php:437) in /home/mysite/public_html/includes/joomla.php on line 808 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/mysite/public_html/includes/joomla.php:437) in /home/mysite/public_html/includes/joomla.php on line 808 I've attached the php file giving the errors, I hope someone can help me. Thanks in advance. Jude Edited October 29, 2014 by glow Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted October 29, 2014 Share Posted October 29, 2014 You can set the time zone with date_default_timezone_set(): http://php.net/manual/en/function.date-default-timezone-set.php As for the others errors, session_start() needs to be called before anything is outputted to the browser. http://php.net/manual/en/function.session-start.php Quote Link to comment Share on other sites More sharing options...
glow Posted October 29, 2014 Author Share Posted October 29, 2014 Thank you for your links but this still goes over my head , I wish I understood more of it but I'm not there yet. So in my joomla.php it shows this code in line 103: ----------------------------------------------------- $now = date( 'Y-m-d H:i', time() ); DEFINE( '_CURRENT_SERVER_TIME', $now ); DEFINE( '_CURRENT_SERVER_TIME_FORMAT', '%Y-%m-%d %H:%M:%S' ); and this code in line 436: $now = date( 'Y-m-d H:i:s', time() ); $this->set( 'now', $now ); ---------------------------------------------------------- so what should go in their place? thanks you Quote Link to comment Share on other sites More sharing options...
ginerjm Posted October 29, 2014 Share Posted October 29, 2014 As was said - you need to read the manual on how to use 'date_default_timezone_set' and place it at the top of your script. Ideally it would be in your php.ini (configuration file) but apparently it is not. Then you need to add 'session_start()' at the top of each of your scripts. Make it a habit. Of course if you are not using any session vars in that script I guess you could ignore it, but I use it as part of my std. template just to be sure I don't forget it later. Quote Link to comment Share on other sites More sharing options...
glow Posted October 29, 2014 Author Share Posted October 29, 2014 I tried this but it didn't work: <?php date_default_timezone_set('America/Los_Angeles');$script_tz = date_default_timezone_get();if (strcmp($script_tz, ini_get('date.timezone'))){ echo 'Script timezone differs from ini-set timezone.';} else { echo 'Script timezone and ini-set timezone match.';}?> Quote Link to comment Share on other sites More sharing options...
ginerjm Posted October 29, 2014 Share Posted October 29, 2014 Not sure why you wrote all that code. Your error message implied that there was no timezone set but this indicates that there may have been one. Are you in the same script, using the same .ini file for settings? Quote Link to comment Share on other sites More sharing options...
glow Posted October 29, 2014 Author Share Posted October 29, 2014 Adding "session_start()" to the top of the script gives errors also. Quote Link to comment Share on other sites More sharing options...
glow Posted October 29, 2014 Author Share Posted October 29, 2014 I simply copied that example code from the link you provided and add it to my php page. Quote Link to comment Share on other sites More sharing options...
Solution mogosselin Posted October 29, 2014 Solution Share Posted October 29, 2014 It seems to me like you're fairly new to PHP and you're trying to do something with Joomla? If you don't understand the error messages and you're 'playing' with Joomla, it's normal that you're lost... Also, if you copy a piece of code and put it there in the hope that it'll work (without understanding how it works), well... the changes are that it won't work All the code that you copied from the timezone thing isn't necessary. You just need something like: date_default_timezone_set('America/Los_Angeles'); You should choose the timezone of your PHP server from the list here: http://php.net/manual/en/timezones.php Don't just write 'Los_Angeles' if your server isn't in the same timezone, you'll end up with weird results. All the rest of the code in the example is just meant to check if the timezone you set in your code is the same as in your INI settings. When I say "ini settings", it means your PHP configurations. Do you know where your php.ini file is and what it contains? For the other error message, it's similar to the popular 'Headers already sent' error. The 'Header' is something that your server will send to the browser requesting the page. But, the header needs to be first, before any content is sent. And, the header contains cookies (and cookies are used to manage sessions). So, if you send content to the browser (like with a echo "hello", or a blank space, etc.), and then you try to add a cookie, it won't work. The header was already sent... If you want a detailed explanation on how this work, I already wrote a post about it (it's not the exact same error, but it's similar). That being said, why are you using Joomla? Can't you just start with plain PHP and do a simple 'contact form' or any other simple application? It would be, IMO, a better way to start with PHP. Quote Link to comment Share on other sites More sharing options...
glow Posted October 29, 2014 Author Share Posted October 29, 2014 Hey thanks for your help, that worked out nicely. I hate joomla i'm just helping out a friend : ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.