I don\'t understand
Не понимаю, в чем заключается ошибка
query(\"SET
you can try like this....you have to fetch that array and you can print....
<?php
$mysqli = new mysqli ('localhost', 'root', '', 'db_name');
$mysqli->query("SET NAMES 'utf-8'");
$result_set= mysqli_query($mysqli,"SELECT * FROM products");
$row=mysqli_num_rows($result_set);
echo $row;
while($row=mysqli_fetch_array($result_set))
{
print_r($row);
}
?>
$result_set
is outside the function scope. You can't access it within the function. Try the following changes:
<?php
function printResult () {
$mysqli = new mysqli ('localhost', 'root', '', 'UTS');
$mysqli->set_charset("utf-8"); //Better to do it this way
$result_set = $mysqli->query ("SELECT * FROM `product`"); //Not the ` instead of '
while (($row = $result_set->fetch_assoc()) != false) {
print_r ($row);
echo "<br/>";
}
$mysqli -> close();
}
You can run this function from anywhere.