title: Checking already existing username or not MySQL, PHP
body: <p>I Cannot Check whether the username already exist in database. I gone through existing questions that were answered here. None of them solved my problem. When i executes, it displays "Cannot select username from table", which i given inside die block. Code Is given below.</p>
  
  <pre><code>&lt;?php
      $username = $_POST['user_name'];
      $password = $_POST['pass_word'];
  
      $host = "localhost";
      $db_username = "root";
      $db_password = "";
      $db_name = "my_db";
  
      //create connection
      $conn = @new mysqli($host, $db_username, $db_password, $db_name);
  
      if (isset($_POST["submit"]))
      {
          # code...
  
          //check  connection established or not
          if ($conn-&gt;connect_error)
          {
              die("Not Connected to DB"); 
          }
          else
          {
              $query = "SELECT 'usernamedb' FROM 'registration' WHERE usernamedb='$username'";
              $result = mysqli_query($conn, $query) or die('Cannot select username from table');
              if (mysqli_num_rows($result)&gt;0)
              {
                  $msg.="This username already exist. try Another !!";
              }
              else
              {
                  $insert = "INSERT INTO 'registration'('id', 'usernamedb', 'password') VALUES ([$username],[$password])";
                  $insert_result = mysqli_query($conn,$insert) or die('INSERTION ERROR');
              }
          }
          $conn-&gt;close();
      }
  ?&gt;
  </code></pre>
  
  <p>Hope someone will answer me.</p>