mysqlnd mysql,PHP脚本从Mysqlnd转换为mysqli

Anyone help me to find the alternative code for my script because it requires Mysqlnd and many online servers don't have this so if I use this code It will give me this error

Fatal error: Call to undefined method mysqli_stmt::get_result()

So I want someone to change my code into mysqli version.

My Code:

$page_id = mysqli_real_escape_string($con, $page_id);

$select_query = $con->prepare("select ID, Title, image, Cost, Vid, content from mobs where ID=?");

$select_query->bind_param('i', $page_id);

$select_query->execute();

$result = $select_query->get_result();

while ($row = mysqli_fetch_array($result, MYSQL_ASSOC))

{

$post_id = $row['ID'];

$post_title = $row['Title'];

Update 1

if(isset($_GET['ID'])){

$page_id = $_GET['ID'];

$page_id = mysqli_real_escape_string($con, $page_id);

$select_query = $con->prepare("select ID, Title, image, Cost, Vid, content from mobs where ID=?");

$select_query->execute();

$select_query->bind_result($post_id, $post_title, $post_image, $post_cost, $post_vid, $post_cont);

while ($select_query->fetch()) {

$post_id = $row['ID'];

$post_title = $row['Title'];

$post_image = $row['image'];

$post_cost = $row['Cost'];

$post_vid = $row['Vid'];

$post_cont= $row['content'];

$sign = '$';

$sign = mysql_real_escape_string($sign);

?>

Update 3

if(isset($_GET['ID'])){

$page_id = $_GET['ID'];

$select_query = ("select ID, Title, image, Cost, Vid, content from mobs where ID=?");

$select_query->execute();

$select_query->bind_result($post_id, $post_title, $post_image, $post_cost, $post_vid, $post_content);

while ($select_query->fetch())

echo 'Post ID:', $post_id, '
',

'Post title: ', $post_title;

{

解决方案

mysqli_stmt::get_result is only available in PHP >= 5.3.0.

I suggest using bind_result instead.

Also, you don't need to escape any strings used in bind_param.

$select_query->execute();

$select_query->bind_result($post_id, $post_title, $post_image, $post_cost, $post_vid, $post_content);

while ($select_query->fetch()) {

// do stuff with the bound result variables, eg

echo 'Post ID:', $post_id, '
'

'Post title: ', $post_title;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值