boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

last update hack and HELP!!!

 
Post new topic   Reply to topic    boardom Forum Index -> Hacks
View previous topic :: View next topic  
Author Message
nicolai



Joined: 25 Jan 2002
Posts: 6
Location: copenhagen, denmark

PostPosted: Sat Sep 04, 2004 8:40 am    Post subject: last update hack and HELP!!! Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
stevem



Joined: 15 Mar 2003
Posts: 249

PostPosted: Sat Sep 04, 2004 8:28 pm    Post subject: Re: last update hack and HELP!!! Reply with quote

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
View user's profile Send private message
nicolai



Joined: 25 Jan 2002
Posts: 6
Location: copenhagen, denmark

PostPosted: Sun Sep 05, 2004 5:51 am    Post subject: Reply with quote

thanks Smile 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... Sad
Back to top
View user's profile Send private message Send e-mail Visit poster's website
stevem



Joined: 15 Mar 2003
Posts: 249

PostPosted: Sun Sep 05, 2004 12:32 pm    Post subject: Reply with quote

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
View user's profile Send private message
nicolai



Joined: 25 Jan 2002
Posts: 6
Location: copenhagen, denmark

PostPosted: Sun Sep 05, 2004 3:01 pm    Post subject: Reply with quote

YES thank you thank you thank you, though perhaps a simple error I really appreciate your help...
thanks...
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> Hacks All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group