I have a perfectly working small database, there is a table exactly named "Category" which in it´s turn has a row named exactly "Name". I've tried every version (Capitalized and not) of the names but my function doesn't return what I want it to return. Anyone out there spotting an obvious error? The database connects just fine... Or am I looking at something seriously troublesome db-conflict.
This is my functions.php which I've included into index.php and had a function call at body. "<?php display_menus(); ?>
<?php
//Connect to database
$link = mysqli_connect('localhost', 'root', 'root');
if (!$link)
{
$output = 'Unable to connect to the database server.';
echo $output;
exit();
}
if (!mysqli_set_charset($link, 'utf8'))
{
$output = 'Unable to set database connection encoding.';
echo $output;
exit();
}
if (!mysqli_select_db($link, 'Asperod6'))
{
$output = 'Unable to locate the "Asperod6" database.';
echo $output;
exit();
}
$output = 'Database connection established.';
echo $output;
//Funktion som skriver ut meny
function display_menus()
{
$result = mysqli_query($link, "SELECT * FROM Category");
if (!$result)
{
$error = 'Error fetching Kategorier: ' . mysqli_error($link);
echo ("There is none");
}
if (mysqli_num_rows($result) > 0)
{
echo "<ul>";
while ($row = mysqli_fetch_array($result))
{
echo "<li>" . $row['Name'] . "</li>";
}
echo "</ul>";
mysqli_free_result($result);
}
}
mysqli_close($link);
?>