Mysqli query return empty results

2019-06-24 08:39发布

im trying to get some data from my DB using this code:

<?php

error_reporting(E_ALL);
ini_set('display_errors',1);


$mysqli2 = new mysqli(********************);

    if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
   }

    $sql2 = "SELECT message FROM wall_workouts_names WHERE id = ? ";

    $stmt2 = $mysqli2->prepare($sql2) or trigger_error($mysqli2->error."[$sql2]");

    $id_for_wall = '43';

    $stmt2->bind_param('s', $id_for_wall);

    $stmt2->execute();

    $stmt2->bind_result($message);

    $stmt2->store_result();

    $stmt2->fetch();

        echo $message;

?>

My problem is that i get empty string in my echo.

But if i run the same query in my phpmyadmin i get good results.

Thanks for helping

标签: php mysqli
2条回答
Evening l夕情丶
2楼-- · 2019-06-24 09:29

Most likely there are no row to match condition in your WHERE clause, namely with id = 43

查看更多
我命由我不由天
3楼-- · 2019-06-24 09:29

Check your incoming results like this.

 while ($stmt->fetch()) {
   echo $message;    
 }
查看更多
登录 后发表回答