I'm working on my graduation project. I'm using MySQLi, and I like to use prepared statements.
I'm currently working on the template system, which I'm doing my self, but when I try to request the theme from the settings table in my database, this happens:
Fatal error: Uncaught exception 'mysqli_sql_exception' with message 'No index used in query/prepared statement SELECT value FROM ws_settings WHERE name = ?' in C:\xampp\htdocs\_inc\_classes\template.class.php:58 Stack trace: #0
C:\xampp\htdocs\_inc\_classes\template.class.php(58): mysqli_stmt->execute() #1
C:\xampp\htdocs\_inc\_classes\template.class.php(73): template->getTheme() #2
C:\xampp\htdocs\_inc\_classes\template.class.php(111): template->loadPage() #3
C:\xampp\htdocs\index.php(40): template->handlePageLoad(0) #4
{main} thrown in C:\xampp\htdocs\_inc\_classes\template.class.php on line 58
So I tought, lets just go to line 58 of template.class.php and this is what I see:
public function getTheme()
{
$theme = 'theme';
$query = $this->db->connection->prepare( 'SELECT value FROM ' . $this->functions->prefix( 'settings' ) . ' WHERE name = ?' );
$query->bind_param( 's', $theme );
$query->execute();
if ( ! $query )
{
throw new Exception( $query->error(), 1 );
}
$query( $result );
while ( $stmt->fetch() )
{
return $result;
}
$query->close();
}
For the sake of making this a good question, I pasted the whole function here. I used this for error_reporting:
error_reporting( E_ALL );
mysqli_report( MYSQLI_REPORT_ALL | MYSQLI_REPORT_STRICT );
If you guys know what the problem is, please help me by telling it, since I have to make this fully A grade for school.
Thanks.