Results 1 to 12 of 12

Thread: COUNT SELECT statement

Threaded View

  1. #1

    Thread Starter
    Fanatic Member LITHIA's Avatar
    Join Date
    Dec 2002
    Location
    UK, England
    Posts
    575

    Resolved COUNT SELECT statement

    Hi,

    I am trying to count the results you will get from my query, but it doesn't seem to let me.

    PHP Code:
    $query mysql_query("SELECT COUNT(*) FROM messages WHERE username = '".$_SESSION[username]."' AND read = '0'"$db); 
    When I try doing a result on that (eg. $result = mysql_result($query, 0, 0);), it gives me a parse error:
    Warning: mysql_result(): supplied argument is not a valid MySQL result resource

    But if I do:
    PHP Code:
    $query mysql_query("SELECT COUNT(*) FROM messages WHERE username = '".$_SESSION[username]."'"$db); 
    it allows it! Which would be ok if I didn't need to specify "read = '0'" too, but I do.

    Can anyone help me here? I'm new to php and I'm not sure what I'm doing wrong. If no one can help, I'll try a different, more sloppy, method.
    Last edited by LITHIA; Mar 6th, 2005 at 04:36 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width