PHP $ MySqli-> fetch всегда возвращает 0 результатов из таблицы MySQL - PullRequest
0 голосов
/ 14 сентября 2018

Этот код всегда возвращает 0, даже если прямой SQL-тест возвращает 1 результат. Я проверил ошибки во всем коде, чтобы увидеть, вернул ли каждый шаг true или результат. Я думаю, я забываю что-то очевидное, но я так расстроен, что не вижу этого.

// Create connection
$mysqli = new mysqli($servername, $username, $password, $database);

// Check connection
if ($mysqli->connect_error) { die("Connection failed: " . $mysqli->connect_error);}

//--------------------------Connection Successful -----------------------------//
$t1 = "SELECT * FROM `customer_info` WHERE `transaction` = ?";
$transaction = "345673245Vkd_";

if ($mysqli->connect_error) {
    printf('connect error (%d) %s', $mysqli->connect_errno, htmlspecialchars($mysqli->connect_error)); }


$stmt = mysqli_prepare($mysqli, $t1);

if ( !$stmt ) { printf('prepare failed: %s', htmlspecialchars($mysqli->error)); }

$rc = mysqli_stmt_bind_param($stmt,'s',$transaction);
if ( !$rc ) { printf('bind_param failed: %s', htmlspecialchars($stmt- >error)); }

$rc = mysqli_execute($stmt);
if ( !$rc ) { printf('execute failed: %s', htmlspecialchars($stmt->error)); }

 mysqli_stmt_bind_result($stmt, $match['0'],$match['1'], $match['2'],$match['3'], $match['4'], $match['5'], $match['6'], $match['7'], $match['8'], $match['9'], $match['10'], $match['11'], $match['12'], $match['13']);

 print_r($match); echo "<br>";

 while($test = $stmt->fetch()){
      printf("%s %s\n", $match['0'], $match['1'], $match['2'], $match['3'],$match['4'], $match['5'], $match['6'], $match['7'], $match['8'], $match['9'], $match['10'], $match['11'], $match['12'], $match['13']);
    echo $stmt->num_rows();

}

$stmt->num_rows();
echo mysqli_stmt_num_rows($stmt);

это печатает

 Array ( [0] => [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] => [9] => [10] => [11] => [12] => [13] => ) 
 Array ( [0] => [1] => [2] => [3] => [4] => [5] => [6] => [7] => [8] => [9] => [10] => [11] => [12] => [13] => )

и никаких ошибок при проверке ошибок.

// ---------------------- ОБНОВЛЕНИЕ ---------------------- - // Удаление WHERE transaction =? вернулся:

Array ( [0] => 
[1] => 345673245Vkd_ 
[2] => rem_reb_dpljnzl 
[3] => blank.email@hotmail.com 
[4] => eBook Title Example 
[5] => 302864487819 
[6] => $1.99 [7] => 1 
[8] => Remmy 
[9] => Example 
[10] => 1122 Example Drive 
[11] => United States 
[12] => MO [13] => 12345 )
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...