regoch Posted July 26, 2011 Share Posted July 26, 2011 Hy! I get this error when I run this script: Notice: A non well formed numeric value encountered in H:\index.php on line 106 Script work fine, get date out mysql and show it but show this error too. I work on small news portal and get this copy/paste from other news portal that I work on, and on that other portal showing no errors. this is from mysql table: news_date timestamp CURRENT_TIMESTAMP <?php $rezultat=mysql_query("SELECT * FROM news ORDER BY news_id DESC LIMIT 1"); while ($redak=mysql_fetch_array($rezultat)) { //Tu razdvaja datum na djelove $dateArray=explode('-',$redak['news_date']); $dan=date('d', mktime(0, 0, 0, $dateArray[1], $dateArray[2], $dateArray[0])); $mjesec=date('m', mktime(0, 0, 0, $dateArray[1], $dateArray[2], $dateArray[0])); $godina=date('Y', mktime(0, 0, 0, $dateArray[1], $dateArray[2], $dateArray[0])); //Tu pretvara broj mjesec iz broja u tekst $mjesec_ime = array( "01"=>"siječanj", "02"=>"veljača", "03"=>"ožujak", "04"=>"travanj", "05"=>"svibanj", "06"=>"lipanj", "07"=>"srpanj", "08"=>"kolovoz", "09"=>"rujan", "10"=>"listopad", "11"=>"studeni", "12"=>"prosinac", ); $mjesec_ime1 = $mjesec_ime[strtolower($mjesec)]; ?><div id="datum_novosti_index"><span style="font-size:28px;"><?php echo $dan; ?>.</span><br /><?php echo $mjesec_ime1; ?></div> <div id="naslov_novosti_index"><?php echo $redak['news_naslov']; ?></div> <?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/242823-notice-a-non-well-formed-numeric-value-encountered/ Share on other sites More sharing options...
silkfire Posted July 26, 2011 Share Posted July 26, 2011 Which line is it in the code you posted? It can't be 106... Quote Link to comment https://forums.phpfreaks.com/topic/242823-notice-a-non-well-formed-numeric-value-encountered/#findComment-1247176 Share on other sites More sharing options...
regoch Posted July 26, 2011 Author Share Posted July 26, 2011 Sorry! for $dan=date('d', mktime(0, 0, 0, $dateArray[1], $dateArray[2], $dateArray[0])); $mjesec=date('m', mktime(0, 0, 0, $dateArray[1], $dateArray[2], $dateArray[0])); Quote Link to comment https://forums.phpfreaks.com/topic/242823-notice-a-non-well-formed-numeric-value-encountered/#findComment-1247182 Share on other sites More sharing options...
silkfire Posted July 26, 2011 Share Posted July 26, 2011 Does your date look like this: 2011-05-22? In that case use strtotime() it's much more efficient. $date = strtotime($redak['news_date']); $dan = date('d', $date); $mjesec = date('m', $date); Quote Link to comment https://forums.phpfreaks.com/topic/242823-notice-a-non-well-formed-numeric-value-encountered/#findComment-1247186 Share on other sites More sharing options...
regoch Posted July 26, 2011 Author Share Posted July 26, 2011 Works great! Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/242823-notice-a-non-well-formed-numeric-value-encountered/#findComment-1247188 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.