I've made this function Note: Functions aren't a strong point for me, yet)
// Query to get all PM's, new or old, limited by #
function pmGet($id, $get, $limit) {
// $get defauled to 'all'
// 'new' shows the newest PM's
// 'newold' gets all PM's but displays new one's first
switch($get) {
// All
case "all" :
$query = mysql_query("SELECT * FROM private_msg WHERE sent_to = '".$id."' ORDER BY date DESC LIMIT 0, $limit") or die(mysql_error());
break;
// New
case "new" :
$query = mysql_query("SELECT * FROM private_msg WHERE is_new = '1' AND sent_to = '".$id."' ORDER BY date DESC LIMIT 0, $limit") or die(mysql_error());
break;
// New Old
case "newold" :
$query = mysql_query("SELECT * FROM private_msg WHERE is_new = '1' AND sent_to = '".$id."' ORDER BY is_new AND date DESC LIMIT 0, $limit") or die(mysql_error());
break;
}
// Fetch results
$row = mysql_fetch_object($query);
// Return
return $row;
}
// Get all PM's in a variable
$smarty->assign('getPMs', pmGet($_COOKIE['userID'], 'new', 5));
Urm... basically, depending on what $get is, it will display your messages.
When I output it, I don't get any results, I get this: Which I've never seen before
Quote
Object id #2
Anybody know what might be wrong?
