J
J
JackShcherbakov2018-05-14 20:53:19
PHP
JackShcherbakov, 2018-05-14 20:53:19

Why is it impossible to extract rows from the database?

Hello colleagues! I recently ran into the following problem:
I don't know what's wrong, but the bottom line is that if you enter the query "SELECT title FROM tours" through PhpMyAdmin, then everything works as it should.
But for some reason, through PHP, I can't do the same:

<?php
include("modules/php/database.php");
$db = db_connect();
$query = "SELECT title FROM tours";
$stmt = $db->prepare($query);
$stmt->bind_result($title);
while($stmt->fetch()){
  echo $title;
}
?>

As a result, nothing is displayed on the screen. $db->error is empty.
What is the problem? What am I doing wrong?
I would like to thank everyone in advance who will help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JackShcherbakov, 2018-05-14
@JackShcherbakov

How careless I am! I forgot $stmt->execute(). Hmm...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question