Forum Index   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
starteck2002Offline



Joined: Nov 30, 2004
Posts: 4
Location: 2
Status: Offline
Post   Posted: Aug 29, 2005 - 10:03 PM Reply with quote Back to top

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 Sad

Anyone have any ideas?

I can give full access to my site for anyone who is interested in getting this working.

TIA, Dave
View user's profile Send private message
Chestnut
Site Admin


Joined: Oct 08, 2003
Posts: 1065
Location: Paris - France
Post   Posted: Aug 29, 2005 - 10:19 PM Reply with quote Back to top

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....."
Wink

_________________
Chestnut ! Cool
Administrator
PNConcept.com
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
starteck2002Offline



Joined: Nov 30, 2004
Posts: 4
Location: 2
Status: Offline
Post   Posted: Aug 29, 2005 - 11:23 PM Reply with quote Back to top

I must be doing something wronmg Sad

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 Smile



Image

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';
    }
   
}
View user's profile Send private message
Chestnut
Site Admin


Joined: Oct 08, 2003
Posts: 1065
Location: Paris - France
Post   Posted: Aug 30, 2005 - 12:06 AM Reply with quote Back to top

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................ Question

By the way... only to put that question away... I hope for you that you have at least 1 unread message because if not... Wink

_________________
Chestnut ! Cool
Administrator
PNConcept.com


Last edited by Chestnut on Aug 30, 2005 - 12:07 AM; edited 1 time in total
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
Chestnut
Site Admin


Joined: Oct 08, 2003
Posts: 1065
Location: Paris - France
Post   Posted: Aug 30, 2005 - 12:09 AM Reply with quote Back to top

aw dammit.......

Code:

    $tbl    = $pntable['pn_messenger'];
    $column = &$pntable['pn_read_msg'];



SIGH !!!! SO WRONG !!!!!!! Laughing

Should be :

Code:

    $tbl    = &$pntable['messenger'];
    $column = &$pntable['messenger_column'];

_________________
Chestnut ! Cool
Administrator
PNConcept.com
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
starteck2002Offline



Joined: Nov 30, 2004
Posts: 4
Location: 2
Status: Offline
Post   Posted: Aug 30, 2005 - 09:32 AM Reply with quote Back to top

yes, there is at least one unread message Wink

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 Sad

Anyone heard any news about Alex (PortalZine)? Hope he's ok.
View user's profile Send private message
starteck2002Offline



Joined: Nov 30, 2004
Posts: 4
Location: 2
Status: Offline
Post   Posted: Aug 30, 2005 - 12:32 PM Reply with quote Back to top

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....
View user's profile Send private message
Chestnut
Site Admin


Joined: Oct 08, 2003
Posts: 1065
Location: Paris - France
Post   Posted: Aug 30, 2005 - 01:25 PM Reply with quote Back to top

mmm... I don't see much...

The where is there.

_________________
Chestnut ! Cool
Administrator
PNConcept.com
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits
DarkMindZ