PHP MySQLi准备的语句-SELECT [英] PHP MySQLi prepared statements - SELECT
本文介绍了PHP MySQLi准备的语句-SELECT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的SELECT语法有问题. 代码:
I have problems with my SELECT syntax. Code:
$stmt = $this->con->prepare("SELECT ? FROM `shop_items` WHERE `id` = ?");
$stmt->bind_param("si", $what, $itemsId);
$stmt->execute();
$stmt->bind_result($res);
$stmt->fetch();
echo $res;
当我想选择名称"时,它回显名称"而不是来自数据库的结果.如何解决?
When I want to select "name", it echo "name" instead of result from DB. How to solve it?
推荐答案
似乎您在SELECT之后使用问号(?).它应该是*符号,您可以从"shop_items"中全部选择.您可以再试一次.
It looks like you use question mark (?) after SELECT. It should be * symbol where you can select it all from 'shop_items'. You can try again with that.
这篇关于PHP MySQLi准备的语句-SELECT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文