I'm trying to create a class with a function in one php file, and the access it from another. But I can't get it to work. I get Fatal error: Class 'databaseConnect' not found
.
The code:
<?php
$conn = new mysqli("localhost", "root", "usbw", "beoordelingen") or die(mysql_error());
class database {
public function getDatabase($theVar, $theSelector, $theLocator) {
$theVar = $conn->query("SELECT $theSelector FROM beoordeling $theLocator");
}
}
?>
Then trying to call it in another file:
<?php
include("myClassFile.php");
$index = new database();
$index->getDatabase($result, "DISTINCT `category`");
?>
Does it have something to do with scope or namespace? Or am I just doing something wrong here.