简体   繁体   中英

Mysqli query return empty results

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

很可能在WHERE子句中没有要匹配条件的行,即id = 43

Check your incoming results like this.

 while ($stmt->fetch()) {
   echo $message;    
 }

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