| Author |
Message |
starteck2002
Joined: Nov 30, 2004
Posts: 4
Location: 2
Status: Offline
|
  Posted:
Aug 29, 2005 - 10:03 PM |
|
| Code: | // make sure the user is logged in
if (pnUserloggedin()){
// pre .750 connection
// list($dbconn) = pnDBGetConn();
////////////////////////////////////////
// 750+ connection
$dbconn =& pnDBGetConn(true);
$pntable =& pnDBGetTables();
////////////////////////////////////////
$pntable = pnDBGetTables();
$column = &$pntable['priv_msgs_column'];
$result = $dbconn->Execute("SELECT count(*) FROM $pntable[priv_msgs] WHERE $column[read_msg] ='0' and $column[to_userid]='".pnUserGetVar('uid')."'");
list($unread) = $result->fields;
if($unread >=1){
echo '<img src="path/to/flashing/image.gif" />';
}
} |
This bit of code will display a gif image if there is any unread PM's. I purchased PMBOX Messenger from PortalZine and this code does not work for that (looks at wrong tables). Alex (of PortalZine) has not been around for a while due to illness so I can't ask him and to add to that he has encoded his block with ioncube so i can't look at that either
Anyone have any ideas?
I can give full access to my site for anyone who is interested in getting this working.
TIA, Dave |
|
|
|
 |
Chestnut
Site Admin
Joined: Oct 08, 2003
Posts: 1065
Location: Paris - France
|
  Posted:
Aug 29, 2005 - 10:19 PM |
|
Little clean up first
| Code: |
// make sure the user is logged in
if (pnUserloggedin()) {
// if code must look in a 3rd party, make sure the module tables are loaded
// pnModDBInfoLoad('pmBOX');
$dbconn =& pnDBGetConn(true);
$pntable =& pnDBGetTables();
$tbl = $pntable['priv_msgs'];
$column = &$pntable['priv_msgs_column'];
$result = $dbconn->Execute("SELECT count(*)
FROM $tbl
WHERE $column[read_msg] = '0'
AND $column[to_userid] = '".pnUserGetVar('uid')."'");
list($unread) = $result->fields;
if($unread >=1){
echo '<img src="path/to/flashing/image.gif" />';
}
}
|
Now I modified the table call to give you a more easy way to change the table the code must look in :
| Code: |
$tbl = $pntable['priv_msgs'];
|
And I added the pnModDBInfoLoad that you will probably need if you are getting the tables of the pmBOX instead of the original ones. Just remove the // in front of it.
Lastly, remember to change the "pathto/flashing/image....."
 |
_________________ Chestnut !
Administrator
PNConcept.com |
|
 |
 |
starteck2002
Joined: Nov 30, 2004
Posts: 4
Location: 2
Status: Offline
|
  Posted:
Aug 29, 2005 - 11:23 PM |
|
I must be doing something wronmg
I've changed the tables, added a bit to show the number of messages as well as the graphic but it's still not working. I've attached a screen grab of the DB. I suppose it might help if I actually understood what I was doing. Thanks very much for your help so far Frank
| Code: | // make sure the user is logged in
if (pnUserloggedin()) {
// if code must look in a 3rd party, make sure the module tables are loaded
pnModDBInfoLoad('pmBOX');
$dbconn =& pnDBGetConn(true);
$pntable =& pnDBGetTables();
$tbl = $pntable['pn_messenger'];
$column = &$pntable['pn_read_msg'];
$result = $dbconn->Execute("SELECT count(*)
FROM $tbl
WHERE $column[read_msg] = '0'
AND $column[to_userid] = '".pnUserGetVar('uid')."'");
list($unread) = $result->fields;
if($unread >=1){
echo '<img src="path/to/flashing/image.gif" />';
echo 'Unread Messages:'+'$unread';
}
} |
|
|
|
|
 |
Chestnut
Site Admin
Joined: Oct 08, 2003
Posts: 1065
Location: Paris - France
|
  Posted:
Aug 30, 2005 - 12:06 AM |
|
Variables are not parsed between single quotes :
| Code: |
if($unread >=1){
echo '<img src="path/to/flashing/image.gif" />';
}
echo 'Unread Messages: '.$unread;
|
And lastly, it is better to check if you have an sql error...
| Code: |
$result = $dbconn->Execute("SELECT count(*)
FROM $tbl
WHERE $column[read_msg] = '0'
AND $column[to_userid] = '".pnUserGetVar('uid')."'");
if ($dbconn->ErrorNo() != 0) {
echo $dbconn->ErrorMsg();
}
|
As for the rest................
By the way... only to put that question away... I hope for you that you have at least 1 unread message because if not...  |
_________________ Chestnut !
Administrator
PNConcept.com
Last edited by Chestnut on Aug 30, 2005 - 12:07 AM; edited 1 time in total |
|
 |
 |
Chestnut
Site Admin
Joined: Oct 08, 2003
Posts: 1065
Location: Paris - France
|
  Posted:
Aug 30, 2005 - 12:09 AM |
|
aw dammit.......
| Code: |
$tbl = $pntable['pn_messenger'];
$column = &$pntable['pn_read_msg'];
|
SIGH !!!! SO WRONG !!!!!!!
Should be :
| Code: |
$tbl = &$pntable['messenger'];
$column = &$pntable['messenger_column'];
|
|
_________________ Chestnut !
Administrator
PNConcept.com |
|
 |
 |
starteck2002
Joined: Nov 30, 2004
Posts: 4
Location: 2
Status: Offline
|
  Posted:
Aug 30, 2005 - 09:32 AM |
|
yes, there is at least one unread message
I'll give this a go tonight and see if it works. This is all because I designed a theme and it requires the number of unread pm's to be displayed - i thought it was a really easy task
Anyone heard any news about Alex (PortalZine)? Hope he's ok. |
|
|
|
 |
starteck2002
Joined: Nov 30, 2004
Posts: 4
Location: 2
Status: Offline
|
  Posted:
Aug 30, 2005 - 12:32 PM |
|
| Code: |
// make sure the user is logged in
if (pnUserloggedin()) {
// if code must look in a 3rd party, make sure the module tables are loaded
pnModDBInfoLoad('Messenger');
$dbconn =& pnDBGetConn(true);
$pntable =& pnDBGetTables();
$tbl = $pntable['messenger'];
$column = &$pntable['messenger_column'];
$result = $dbconn->Execute("SELECT count(*)
FROM $tbl
WHERE $column[read_msg] = '0'
AND $column[to_userid] = '".pnUserGetVar('uid')."'");
// if ($dbconn->ErrorNo() != 0) {
// echo $dbconn->ErrorMsg();
// }
list($unread) = $result->fields;
if($unread >=1){
echo '<img src="path/to/flashing/image.gif" />';
}
echo 'Unread Messages: '.$unread;
}
|
This is now working but shows all messages, not just unread messages. Any ideas on what to do next?
Thanks for your help,
Dave
EDIT : Code tag, code tag, code tag, code tag.... |
|
|
|
 |
Chestnut
Site Admin
Joined: Oct 08, 2003
Posts: 1065
Location: Paris - France
|
  Posted:
Aug 30, 2005 - 01:25 PM |
|
mmm... I don't see much...
The where is there. |
_________________ Chestnut !
Administrator
PNConcept.com |
|
 |
 |
|
|