I'm trying to retrieve values from 2 tables in the database. The PHP looks like this:
$conn = Db::getInstance();
$getPosts = $conn->prepare("SELECT DISTINCT board.boardID,
board.userID, board.postID, items.Url, items.Image
FROM board
JOIN items on postID = items.id
WHERE board.userID = 92, board.boardID = 1");
$getPosts->execute();
$p = $getPosts->fetch();
var_dump($p);
I was expecting an array with all the values in it but instead, $p gives me a bool(false). I'd like to echo $p['Url'] in an image tag. What am I doing wrong? Much appreciated!
Replace the comma in the WHERE clause with an AND.
When You have error in your SQL query syntax, it returns boolean "false" that's where you are having problem