SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: error on query

Hybrid View

  1. #1
    Resistance is Futile webgodjj's Avatar
    Join Date
    Nov 2002
    Location
    Madison, WI USA
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    error on query

    Hi, Can you spot the problems with the code below? I am trying to count how many instances of 'Yes' and 'No' in a column called 'opt_in_spe'

    Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource

    PHP Code:
    $result mysql_query("select sum(if(opt_in_spe='Yes',1,0)) as Yes, sum(if(opt_in_spe='No', 1, 0)) as No");
    $optin mysql_fetch_object($result);
    echo 
    "$optin->No";
    echo 
    "$optin->Yes"

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,273
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    from which table?

    :-)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    Resistance is Futile webgodjj's Avatar
    Join Date
    Nov 2002
    Location
    Madison, WI USA
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That sure did it...


Bookmarks

Posting Permissions

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