I want to get a Firstname (Voornaam), and Lastname (Achternaam) from my database with a specific ID.
And I want to put it in my a function.
I made the following function in functions.php:
<?php
/* Naam opvragen */
include('gegevens.php');
function getName($getID)
{
$getname = 'SELECT * FROM KlantGegevens WHERE ID = ' . $getID;
$query = $conn->query($getname);
while($show = $query->fetch_assoc()) {
$voornaam = $show["Voornaam"];
return $voornaam;
}
}
/* Eind naam opvragen */
?>
And i call the function with ($getID (=1)):
<?php getName($getID); ?>
My error is:
Fatal error: Call to a member function query() on a non-object in /home/thijsgp51/domains/thijskempers.nl/public_html/beheer/functions/functions.php on line 8
What am i doing wrong here?