I am trying to put an SQL query in a PHP function but am getting the following error in the terminal
Fatal error: Call to a member function query() on a non-object in /Users/file.php on line 18
Please see line 16 to 22 of my PHP code below:
function testFunction() {
$sql = "SELECT * FROM testNumber WHERE test = '1'"
$result = $conn->query($sql);
return $result->num_rows;
}
$testVariable = $testFunction();
echo $testVariable;