View previous topic :: View next topic |
Author |
Message |
nicolai
Joined: 25 Jan 2002 Posts: 6 Location: copenhagen, denmark
|
Posted: Sat Sep 04, 2004 8:40 am Post subject: last update hack and HELP!!! |
|
|
hi everyone
hope some of you can help me.
I'm trying to extract the date of the latest post and put it on my index page for a "last update" thing, but with no luck though.
the script i'm trying looks like this...
## Functions to print the date and time of the last post [/speza]
function posts_lastdate($d="") {
global $id,$dateformat;
$query = "SELECT post_date FROM b2posts WHERE b2posts.ID=$id ORDER BY b2posts.post_date DESC LIMIT 1;";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
if ($row) {
if ($d=="") {
echo mysql2date($dateformat, $row["posts_date"]);
} else {
echo mysql2date($d, $row["posts_date"]);
}
}
}
I've added this one to b2template.functions.php
and I'm calling it like this <?php posts_lastdate("F d."); ?>
the outcome though is like this "Warning: Missing argument 2 for mysql2date()" and I've been completely unable to do anything about it.
Can anyone help, I'm completely new to php.
/Nicolai |
|
Back to top |
|
 |
stevem
Joined: 15 Mar 2003 Posts: 368
|
Posted: Sat Sep 04, 2004 8:28 pm Post subject: Re: last update hack and HELP!!! |
|
|
nicolai wrote: | $query = "SELECT post_date FROM b2posts WHERE b2posts.ID=$id ORDER BY b2posts.post_date DESC LIMIT 1;";
...
echo mysql2date($d, $row["posts_date"]); |
$row["posts_date"] doesn't exist (hence the warning) as it should be $row["post_date"] to agree with SELECT post_date |
|
Back to top |
|
 |
nicolai
Joined: 25 Jan 2002 Posts: 6 Location: copenhagen, denmark
|
Posted: Sun Sep 05, 2004 5:51 am Post subject: |
|
|
thanks that helped me past the first hurdle although after editing the script I get this warning "mysql_fetch_array(): supplied argument is not a valid MySQL result" again I'm not quite sure what that means...  |
|
Back to top |
|
 |
stevem
Joined: 15 Mar 2003 Posts: 368
|
Posted: Sun Sep 05, 2004 12:32 pm Post subject: |
|
|
It means that the SQL is wrong. How about:
Code: | $query = "SELECT post_date FROM $tableposts WHERE ID=$id ORDER BY post_date DESC LIMIT 1"; |
Does it work - of course you must give a valid $id for it to do so. |
|
Back to top |
|
 |
nicolai
Joined: 25 Jan 2002 Posts: 6 Location: copenhagen, denmark
|
Posted: Sun Sep 05, 2004 3:01 pm Post subject: |
|
|
YES thank you thank you thank you, though perhaps a simple error I really appreciate your help...
thanks... |
|
Back to top |
|
 |
|