简体   繁体   中英

Query not giving the expected results in PHP

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!

用AND替换WHERE子句中的逗号。

当您的SQL查询语法出错时,它会返回布尔值“false”,表示您遇到问题

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM