Jump to content

[SOLVED] HELP! new to php mysql. Need help with parsing error for date.


vram1980

Recommended Posts

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()

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));

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.