unkn0wndj Posted March 26, 2006 Share Posted March 26, 2006 Alright I was wanting to pull information from a MySQL database. Heres the code im using[code]$mnum = mysql_query("select * from messages where msg_recieverid='$_SESSION[usrid]'");$mnumber = mysql_num_rows($mnum);[/code]Alright so I was wondering.. I need to have the msg_recieverid still included because that's what tells it to pull only from their ID, but what I really need to know is msg_read='U' because that says that the message is unread and thats the whole purpose of it. So how can I make a command that lets me pull the number of msg_read='U' that someone has for their msg_recieverid..Please help Quote Link to comment https://forums.phpfreaks.com/topic/5830-mysql-php-issue/ Share on other sites More sharing options...
fenway Posted March 26, 2006 Share Posted March 26, 2006 Assuming you just need the count, and not the actual messages, then the following should suffice:[code]SELECT COUNT(*) AS cnt FROM messages WHERE msg_recieverid='$_SESSION[usrid]' AND msg_read ='U'[/code]Then pull back the single row containing the count with mysql_fetch_array(). Quote Link to comment https://forums.phpfreaks.com/topic/5830-mysql-php-issue/#findComment-20783 Share on other sites More sharing options...
unkn0wndj Posted March 26, 2006 Author Share Posted March 26, 2006 [!--quoteo(post=358465:date=Mar 25 2006, 11:51 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Mar 25 2006, 11:51 PM) [snapback]358465[/snapback][/div][div class=\'quotemain\'][!--quotec--]Assuming you just need the count, and not the actual messages, then the following should suffice:[code]SELECT COUNT(*) AS cnt FROM messages WHERE msg_recieverid='$_SESSION[usrid]' AND msg_read ='U'[/code]Then pull back the single row containing the count with mysql_fetch_array().[/quote]Sorry i dont understand what you mean by" Then pull back the single row containing the count with mysql_fetch_array()."Could you please copy what the code needs to contain for that to work :)oh btw the recieverid is a number Quote Link to comment https://forums.phpfreaks.com/topic/5830-mysql-php-issue/#findComment-20788 Share on other sites More sharing options...
fenway Posted March 26, 2006 Share Posted March 26, 2006 Since it's just going to be one value anyway, you can use the following:[code]$count = mysql_result($query, 0, 0); [/code] Quote Link to comment https://forums.phpfreaks.com/topic/5830-mysql-php-issue/#findComment-20793 Share on other sites More sharing options...
unkn0wndj Posted March 26, 2006 Author Share Posted March 26, 2006 mysql_result(): supplied argument is not a valid MySQL result resource in /home/vhosts/www.nowiby.com/templates/topnav.php on line 20 Quote Link to comment https://forums.phpfreaks.com/topic/5830-mysql-php-issue/#findComment-20841 Share on other sites More sharing options...
wickning1 Posted March 26, 2006 Share Posted March 26, 2006 That happens when there is a MySQL error. Echo mysql_error() to see what it was. Quote Link to comment https://forums.phpfreaks.com/topic/5830-mysql-php-issue/#findComment-20845 Share on other sites More sharing options...
unkn0wndj Posted March 26, 2006 Author Share Posted March 26, 2006 Doesnt say anything maybe my command is wrong ;\ Quote Link to comment https://forums.phpfreaks.com/topic/5830-mysql-php-issue/#findComment-20913 Share on other sites More sharing options...
wickning1 Posted March 26, 2006 Share Posted March 26, 2006 Try$count = mysql_result($mnum, 0, 0); Quote Link to comment https://forums.phpfreaks.com/topic/5830-mysql-php-issue/#findComment-20918 Share on other sites More sharing options...
unkn0wndj Posted March 26, 2006 Author Share Posted March 26, 2006 [!--quoteo(post=358605:date=Mar 26 2006, 02:06 PM:name=wickning1)--][div class=\'quotetop\']QUOTE(wickning1 @ Mar 26 2006, 02:06 PM) [snapback]358605[/snapback][/div][div class=\'quotemain\'][!--quotec--]Try$count = mysql_result($mnum, 0, 0);[/quote]Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /home/vhosts/www.nowiby.com/templates/topnav.php on line 20 Quote Link to comment https://forums.phpfreaks.com/topic/5830-mysql-php-issue/#findComment-20972 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.