-2

The code is successfully connecting to the database but when I try to retrieve data from a database it's not working.

    <?php

      $link = mysqli_connect("server name","username","password");

       if (mysqli_connect_error()) {

       die ("There was an error connecting to the database");

       } 

       $query = "SELECT * FROM users";

         if ($result = mysqli_query($link, $query)) {

             $row = mysqli_fetch_array($result);

             echo "Your email is ".$row[1]." and your password is ".$row[2];

            } else {

            echo mysqli_error($link);

            }

          ?>

1 Answers1

2

you haven't specified to search in which database, on mysqli you should add one more parameter,

$link = mysqli_connect("server name","username","password", "database");