PHP trying to work with classes, but class can't be accessed -
i'm trying create class function in 1 php file, , access another. can't work. 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 beoordeling $thelocator"); } } ?>
then trying call in file:
<?php include("myclassfile.php"); $index = new database(); $index->getdatabase($result, "distinct `category`"); ?>
does have scope or namespace? or doing wrong here.
(1) check whether file exists. you'd better use absolute path well.
(2) whether there namespace scope. try new \databaseconnect(); append back-slash
Comments
Post a Comment