title: MySQL/ PHP/PHPMydamin error
body: <p>I'm VERY new to PHP and MySql and like most beginners I'm trying to make use of things I'm learning so I'm trying to make a simple login/logout system.</p>
  
  <p>I've downloaded WAMP,made my database in PHPMyAdmin and my table etc however I cannot get my PHP code to recognise the data in the database, I simply get 'Query failed'!I can certainly connect the database,and I don't believe the problem is with the database but my login file!I've looked at loads of different tutorial but I still can't get this to work.I'd really appreciate if anyone could point me in the right direction!</p>
  
  <p>If anyone wants to play around with my code thats fine the fields I have in the database are: id, username, password, first name, last name (id is a primary key with auto increment)</p>
  
  <p>My login file is </p>
  
  <pre><code> &lt;?php
      //require 'core.inc.php';
      //echo $current_file;
  
      if (isset($_POST['username'])&amp;&amp; isset ($_POST['password'])){
          $username= $_POST['username'];
          $password= $_POST['password'];
  
          if (empty ($username)&amp;&amp;empty ($password)){
              echo 'supply username and password';
          }
  
          $query = "SELECT * FROM 'test1' WHERE 'username'='$username'AND 'password'='$password'";
          $result= mysql_query($query);
  
      if($result) {
              if(mysql_num_rows($result) &gt; 0) {
                  //Login Successful
                  session_regenerate_id();
                  $member = mysql_fetch_assoc($result);
  
                  $_SESSION['SURNAME_NAME'] = $member['username'];
                  $_SESSION['SESS_ID'] = $member['password'];
                  session_write_close();
  
                  exit();
              }else {
                  //Login failed
                  echo 'user name and password not found';
                  $errflag = true;
                  if($errflag) {
                      $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
                      session_write_close();
  
                      exit();
                  }
              }
          }else {
              die("Query failed");
          }
  
      }
  
  ?&gt;
  
      &lt;form method="POST"&gt;
      Username: &lt;input type = "text" name="username"&gt; Password: &lt;input type ="password" name="password"&gt;
      &lt;input type="submit" value="Log in"&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>and my connect data base file is(I have removed my password on purpose) :</p>
  
  <pre><code>// assign the host user name and database name to variables
  $db_host = "localhost";
  $db_username = "";
  $db_password = "";
  $db_name = "";
  
  session_start();
  // connect to database, if not send error message
  mysql_connect("$db_host", "$db_username", "$db_password") or die ("Could not connect to MySQL.");
  // check database exists, if not send error message
  mysql_select_db("$db_name") or die ("No database.");
  // if sucessful connection etc print out the following!
  //echo("Successful connection established.");
  ?&gt;
  </code></pre>