Can't query database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DavidPr
    New Member
    • Mar 2007
    • 155

    Can't query database

    I'm trying to do this:
    Code:
    $query = "SELECT * FROM response WHERE recipe_id='$file' AND allow='1'";
    $result = mysql_query($query) or trigger_error("Query: $query\n<br>MySQL Error: " . mysql_error());
    if (!$result)
    {
    echo "";
    }
    else
    {
    echo "blah blah";
    }
    But it's not working. It must be something to do with the AND part but I don't know what. Any clues?
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    mysql_query() returns a resource so I wouldn't check that (this should always return true). do you get any errors?

    regards

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      What datatype is 'allow'. If it's ~int, then you shouldn't have single quotes around it.

      Doesn't help when you don't tell use what's isn't happening.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32634

        #4
        David - Check PMs please.

        Comment

        • DavidPr
          New Member
          • Mar 2007
          • 155

          #5
          "allow" is an INT. The field will either have a 1 or 2 in it. When set to 1 the recipe will be displayed and 2 it will not be displayed.

          When a user submits a recipe, the allow field is automatically set to 1. I'm sent an email letting me know that there's a new recipe. I check it to make sure that it is not spam or something and if it's OK I change "allow" to 2, which will make the recipe viewable.

          OK, so NO '' around this number. I'll try it and tell you how it works. Thanks.

          Comment

          • Markus
            Recognized Expert Expert
            • Jun 2007
            • 6092

            #6
            Originally posted by DavidPr
            "allow" is an INT. The field will either have a 1 or 2 in it. When set to 1 the recipe will be displayed and 2 it will not be displayed.

            When a user submits a recipe, the allow field is automatically set to 1. I'm sent an email letting me know that there's a new recipe. I check it to make sure that it is not spam or something and if it's OK I change "allow" to 2, which will make the recipe viewable.

            OK, so NO '' around this number. I'll try it and tell you how it works. Thanks.
            OK, you do that.

            Comment

            Working...