reactphp - Undefined index

0

I am learning reactphp and when I try to pay the information of the database of this error Undefined index I do not know the reason

code that I'm using:

<?php

require 'vendor/autoload.php';

$loop = React\EventLoop\Factory::create();

$server = stream_socket_server('tcp://127.0.0.1:8080');
stream_set_blocking($server, false);

$loop->addTimer(0.8, function () {
    include 'conect.php';
    $sql = "SELECT  'Msn' FROM 'tss'";
    $execut=mysqli_query($link,$sql);
    while($row = mysqli_fetch_row($execut)){
        $msn = $row['Msn'];
        echo $msn . PHP_EOL;
        echo "<br>";
    }
});

$loop->addTimer(0.3, function () {
    include 'conect.php';
    $sql1 = "SELECT  'Usuario' FROM 'tss'";
    $exe =mysqli_query($link,$sql1);
    while($row = mysqli_fetch_row($exe)){
        $usu=$row['Usuario'];
        echo $usu;
    }

});

$loop->run();
?>

connection to the bank:

<?php
$host ="localhost";
$usu="root";
$senha="";
$bd="ts";

$link = mysqli_connect($host, $usu, $senha, $bd);

if (!$link) {
    echo "Error: Falha ao conectar-se com o banco de dados MySQL." . PHP_EOL;
    echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
    echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
    exit;
}

?>

    
asked by anonymous 18.07.2018 / 16:56

1 answer

1

The reason for the error and that you are putting mysqli_fetch_row and right and mysqli_fetch_array ai would be like this

<?php

require 'vendor/autoload.php';

$loop = React\EventLoop\Factory::create();

$server = stream_socket_server('tcp://127.0.0.1:8080');
stream_set_blocking($server, false);

$loop->addTimer(0.8, function () {
    include 'conect.php';
    $sql = "SELECT  'Msn' FROM 'tss'";
    $execut=mysqli_query($link,$sql);
    while($row = mysqli_fetch_array($execut)){
        $msn = $row['Msn'];
        echo $msn . PHP_EOL;
        echo "<br>";
    }
});

$loop->addTimer(0.3, function () {
    include 'conect.php';
    $sql1 = "SELECT  'Usuario' FROM 'tss'";
    $exe =mysqli_query($link,$sql1);
    while($row = mysqli_fetch_array($exe)){
        $usu=$row['Usuario'];
        echo $usu;
    }

});

$loop->run();
?>
    
18.07.2018 / 17:40