Eli Sadoff
Eli Sadoff

Reputation: 7308

PHP MySQL Invalid Query bool(False)

I am working with a MySQL Database with two tables up and info. up has columns ID and Password and info has columns ID, FirstName, LastName, Email, and Reg and ID joins the two tables. I am working in PHP and have this query which is giving me bool(false) on var_dump when I call it

$result = $conn->query("SELECT up.Password FROM up INNER JOIN info ON info.ID = up.ID WHERE info.EMAIL = " . $email);
var_dump($result);
$row = $result->fetch_assoc();

The query works when I query mysql with that identical query and the variable $email returns a proper result when I call var_dump on it.

Upvotes: 1

Views: 83

Answers (1)

Naveed Ramzan
Naveed Ramzan

Reputation: 3593

Whenever we use some text string in any clause in query. Always write with quotes.

like

$query  = "SELECT up.Password FROM up INNER JOIN info ON info.ID = up.ID WHERE info.EMAIL = '".$quer."'";
$result = $conn->query($query);

Upvotes: 1

Related Questions