vram1980 Posted May 25, 2007 Share Posted May 25, 2007 I am setting up a blog for my on personal portfolio and all I need is to format the date! I am ready to curl up and die... i get this parse error when attempting to format the date: Warning: mysql_result(): Thursday May 24th 2007 not found in MySQL result index 9 in /home/content/v/r/a/vram1980/html/inc/sel_blog.php on line 13 Here is the code: $query = "SELECT * FROM blog"; $result = mysql_query($query); $num = mysql_num_rows ($result); if ($num > 0 ) { $i=0; while ($i < $num) { $formatted = date('l F dS Y'); $date = mysql_result($result, $i, $formatted); $title = mysql_result($result,$i,"title"); $entry = mysql_result($result,$i,"entry"); $id = mysql_result($result,$i,"id"); echo "<h4> $title</h4> $date<br>"; echo "<b>entry:</b> $entry<br>"; ++$i; } } else { echo "The database is empty"; } SOMEONE PLEASE HELP ME! the date field is set as DATETIME and the inserts are CURTIME() Quote Link to comment https://forums.phpfreaks.com/topic/52930-solved-help-new-to-php-mysql-need-help-with-parsing-error-for-date/ Share on other sites More sharing options...
Barand Posted May 25, 2007 Share Posted May 25, 2007 The way you have it there, your code is looking for a column with name "Thursday May 24th 2007" try $date = mysql_result($result, $i, 'date'); $formatted = date('l F dS Y', strtotime($date)); Quote Link to comment https://forums.phpfreaks.com/topic/52930-solved-help-new-to-php-mysql-need-help-with-parsing-error-for-date/#findComment-261393 Share on other sites More sharing options...
vram1980 Posted May 25, 2007 Author Share Posted May 25, 2007 wow! thank you! works like a charm! Quote Link to comment https://forums.phpfreaks.com/topic/52930-solved-help-new-to-php-mysql-need-help-with-parsing-error-for-date/#findComment-261397 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.