stuck with PM's

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gaijin
Forum Newbie
Posts: 4
Joined: Sat Jan 17, 2009 10:43 pm

stuck with PM's

Post by gaijin »

Hi guys and girls,

I am new here.. Mike is the name/

I am working on my site and all works nicely.. BUT.. I have a message system inherited in my script and try to make a warning message when new messages come on, and I cant work it out at all.

Can someone tell me how to do this perhaps?

This picture is of my table for the messages, I think that the trick to display when there are messages marked as unread..

Image
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: stuck with PM's

Post by Christopher »

Have you tried a query for msg_read='No' to see if that is what you want?
(#10850)
User avatar
it2051229
Forum Contributor
Posts: 312
Joined: Tue Dec 25, 2007 8:34 pm

Re: stuck with PM's

Post by it2051229 »

you want to display if there is a new message? yup, set the msg_read field as unread when inserting a new message into the database.
gaijin
Forum Newbie
Posts: 4
Joined: Sat Jan 17, 2009 10:43 pm

Re: stuck with PM's

Post by gaijin »

i did that,

But I have no idea how to grab the info and display it.
I do graphics mostly... I can manage the script fine and all, but adding this PM notification seems beyond me.
gaijin
Forum Newbie
Posts: 4
Joined: Sat Jan 17, 2009 10:43 pm

Re: stuck with PM's

Post by gaijin »

Where I go wrong is this,

I know the table to use and all , but there are lots of users...
How can I make sure that user id 3 gets a warning on the screen saying he has 3 messages ...

Sorry all, I feel thick..
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: stuck with PM's

Post by RobertGonzalez »

Select all PMs where the userid is that of the currently logged in user AND the message read flag is set to No.
gaijin
Forum Newbie
Posts: 4
Joined: Sat Jan 17, 2009 10:43 pm

Re: stuck with PM's

Post by gaijin »

Could you show me an example?
User avatar
it2051229
Forum Contributor
Posts: 312
Joined: Tue Dec 25, 2007 8:34 pm

Re: stuck with PM's

Post by it2051229 »

let me guess.. you don't know SQL statements?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Re: stuck with PM's

Post by Burrito »

gaijin wrote:Could you show me an example?

Code: Select all

 
$query = "SELECT * FROM `pmTable` WHERE `userIdField` = '".$_SESSION['uid']."' AND `msg_read` = 'no'";
 
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: stuck with PM's

Post by jaoudestudios »

Burrito wrote:
gaijin wrote:Could you show me an example?

Code: Select all

 
$query = "SELECT * FROM `pmTable` WHERE `userIdField` = '".$_SESSION['uid']."' AND `msg_read` = 'no'";
 
Burrito has kindly shown you an example, but dont stop there, do some research and read around the subject as the above query is not protected against sql injection
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: stuck with PM's

Post by RobertGonzalez »

Can you show an example of how you would inject anything into a session variable in the case of that query? I am interested in seeing how that particular query is susceptible to injection attack.
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: stuck with PM's

Post by jaoudestudios »

Everah wrote:Can you show an example of how you would inject anything into a session variable in the case of that query? I am interested in seeing how that particular query is susceptible to injection attack.
hahaha :lol:
Post Reply