Ario Rakip Ario Rakip - 2 months ago 10
MySQL Question

Unable to retrieve data from MYSQL Database in PHP

I am trying to retrieve the password of a user, when given the email.

$query = "SELECT password FROM `users` WHERE email='$username'";
$result = mysqli_query($query);
$row=mysqli_fetch_array($result);
echo $row;


But it does not seem to work. Can anyone figure what's the problem?

Thanks in advance.

Answer

You Need To Connect To Your Database

$connection = new mysqli('Host Name', 'Username', 'password', 'Database Name', 'port(Optional)');

Second mysqli_query($query); Should Be mysqli_query($connection, $query);

Third $row Is An Array To Echo A Database Value Use $row['column']

Comments