1

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.

2
  • 1
    enclose $email with single quotes. WHERE info.EMAIL = '" . $email."'" Commented Feb 23, 2016 at 2:44
  • 2
    Oh my god thank you so much. I feel like the moron of the century. Commented Feb 23, 2016 at 2:45

1 Answer 1

1

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.