Search code examples
phpmysqlechomamp

print a column from Mysql database


I am trying to print out one column called Language1 from my Table that is called Mull, in a database called v6e.

At the moment i am getting a blank white screen.

<?php
session_start();
$servername = "localhost"; 
$user = "xxxx";
$password = "xxxx";
$dbname = "v6e";

// Create connection
$conn = mysqli_connect($servername, $user, $password, $dbname);

// Check connection
if (!$conn)
{
die("Connection failed: " . mysqli_connect_error());
}
else

{
$query = "SELECT Language1 FROM Mull WHERE username = 'Mull'";
$result = mysqli_query($query);
$row = mysqli_fetch_arrary($result);
echo $row['Language1'];
}
mysqli_close($conn);
?>

Solution

  • You have a typo issue. Change the line:

    $row = mysqli_fetch_arrary($result);
    

    With:

    $row = mysqli_fetch_array($result);
    

    Plus, you're also not connecting to DB with your query

    $result = mysqli_query($conn, $query);
    

    Reference:

    You should also check for errors: