Jump to content

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


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

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.