我与mysql的连接有效,但没有任何查询[重复]

This question already has an answer here:

I'm having a bit of a weird problem. I'm trying to read data of my database, the connection works but the instruction doesn't.

I try with code that should work, query("show tables"); but this also doesn't show anything.

Application is another php in which I make the connection and configuration with the database.

use Aplication as App;

class Company {

public static function login($username, $password) {

      $app = App::getSingleton();
      $conn = $app->conexionBd();

// Check connection

      if ($conn->connect_error) {
          die("Connection failed: " . $conn->connect_error);
        }
echo "Connected successfully";

      $query = sprintf("SELECT * FROM company E WHERE E.Name= %s", $conn->real_escape_string($username));

      $rs = $conn->query($query);



      if ($rs)
      {

        $row = $rs->fetch_assoc();
        $c = new Company($row['id'], $row['Name'],$row['Password']);
        $rs->free();

        return $c;
      }
      return false;
  }
}

What is wrong?

Thanks in advance!

</div>

Best way to troubleshoot such problems is to print the query and run on mysql command prompt.

E.Name= %s should be changed to E.Name= '%s' as strings should be enclosed by quotes.