Php MySQLI使用准备好的语句从表中选择

Php MySQLI使用准备好的语句从表中选择,php,mysqli,prepared-statement,Php,Mysqli,Prepared Statement,我目前正在将我所有的旧MySQL改为MySQLI。但是,在使用准备好的语句时,我在尝试从表中进行选择时遇到了一个问题。标签是一个字符串 我的测试URL是: http://example.com/retreiveCustomArticle.php?Tags=the 我的输出: string(3) "the" string(44) "SELECT `ID` FROM `Articles` WHERE `Tags` = ?" Success!: 0 代码: 您缺少bind\u result()和f

我目前正在将我所有的旧MySQL改为MySQLI。但是,在使用准备好的语句时,我在尝试从表中进行选择时遇到了一个问题。标签是一个字符串

我的测试URL是:

http://example.com/retreiveCustomArticle.php?Tags=the
我的输出:

string(3) "the" string(44) "SELECT `ID` FROM `Articles` WHERE `Tags` = ?" Success!: 0
代码:


您缺少
bind\u result()
fetch()

if($statement->execute()){
如果($statement->bind_result($theId)){/$theId将是从数据库返回的结果
if($statement->fetch()){//if已成功获取
打印“Success!:”.$theId.
;//执行此操作
除了@VotetoClose所说的之外,我建议您:

$statement=$mysqli->prepare('SELECT ID FROM Articles WHERE Tags = ?');
$mysqli->execute(array($_GET['Tags']))

问题是什么?我没有发现任何错误…你能更具体地说明你的错误吗?我没有收到错误。相反,我没有收到预期的输出。预期的输出是什么?接收表中一些记录的JSON。我实际上想要输出JSON格式。我还需要这样做吗?更新了questio吗N
if($statement->execute()){
    if ($statement->bind_result($theId)) { // $theId will be the result that is returned from the database
        if ($statement->fetch()) { // if fetched successfully
             print 'Success!: ' . $theId . '<br />'; // do this
$statement=$mysqli->prepare('SELECT ID FROM Articles WHERE Tags = ?');
$mysqli->execute(array($_GET['Tags']))