MySQL Error

Discussion in 'MySQL' started by Pudge1, Feb 8, 2010.

  1. #1
    
    $connection = mysql_connect('localhost',$user,$pass);
      mysql_select_db($dbname, $connection);
      $vault_id = mysql_real_escape_string( $vault_id );
      $combo = mysql_real_escape_string( $combo );
      $var = "SELECT * FROM Vaults WHERE Vault_ID='". $vault_id . "'";
      $result = mysql_query($var , $connection);
    
      while($row = mysql_fetch_array($result))
       {
        if($row['Vault_ID'] == $vault_id && $row['Combo'] == $combo)
         {
          $var = "SELECT Contents FROM Vaults WHERE Vault_ID='". $vault_id . "'";
          $return = mysql_query($var , $connection);
          return $return;
         }
        else
         {
          return 'FALSE';
         }
       }
    
    Code (markup):
    What I am trying to do is find out if the variable $vault_id and $combo correspondingly match up with two columns Vault_ID and Combo both in the same row. If not it returns false. Otherwise it gets the value of the contents column in that same row. For example:

    Vault_ID | Combo | Contents
    ----------------------------------
    01234 01-01-01 Vault Contents
    12345 02-02-02 More Contents

    If my $vault_id == '01234' and $combo == '01-01-01' then it would return "Vault Contents" or if $vault_id == '12345' and $combo == '02-02-02' it would return "More Contents" otherwise it returns false.

    However it doesn't do this at all. It doesn't return a MySQL error but my host is weird about PHP/MySQL errors so there may be one I am not sure. Do you guys see an error or a mistake I made in syntax. Thanks for at least reading this and attempting to help me.
     
    Pudge1, Feb 8, 2010 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    "SELECT Contents FROM Vaults WHERE Vault_ID = '".$vault_id."' AND Combo = '".$combo."'";
     
    jestep, Feb 9, 2010 IP
  3. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #3
    :\ Still doesn't return anything. Thanks for trying to help though!
     
    Pudge1, Feb 9, 2010 IP