Skip to content

Bug: Constant "MYSQLI_STORE_RESULT" is not defined in the CodeIgniter 4 project, causing an error in the MySQLi database #9158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
phpusrpro opened this issue Aug 28, 2024 · 2 comments

Comments

@phpusrpro
Copy link

PHP Version

8.0

CodeIgniter4 Version

4.1.5

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Linux

Which server did you use?

apache

Database

No response

What happened?

I have a CodeIgniter project (version 4.1.5) installed with Composer and running on PHP 8.0.12.

Whenever I attempt to interact with the database, I encounter an Internal Server Error 500, and the logged message reads as follows:

CRITICAL - 2021-11-13 01:39:18 --> Undefined constant "CodeIgniter\Database\MySQLi\MYSQLI_STORE_RESULT"
#0 D:\Sites\ea4\vendor\codeigniter4\framework\system\Database\Database.php(56): CodeIgniter\Database\Database->initDriver('MySQLi', 'CodeIgniter\\Dat...', Array)
#1 D:\Sites\ea4\vendor\codeigniter4\framework\system\Database\Config.php(78): CodeIgniter\Database\Database->load(Array, 'default')
#2 D:\Sites\ea4\vendor\codeigniter4\framework\system\Model.php(97): CodeIgniter\Database\Config::connect('default')
#3 D:\Sites\ea4\app\Controllers\Backend\Home.php(33): CodeIgniter\Model->__construct()
#4 D:\Sites\ea4\vendor\codeigniter4\framework\system\CodeIgniter.php(824): App\Controllers\Backend\Home->index()
#5 D:\Sites\ea4\vendor\codeigniter4\framework\system\CodeIgniter.php(410): CodeIgniter\CodeIgniter->runController(Object(App\Controllers\Backend\Home))
#6 D:\Sites\ea4\vendor\codeigniter4\framework\system\CodeIgniter.php(318): CodeIgniter\CodeIgniter->handleRequest(NULL, Object(Config\Cache), false)
#7 D:\Sites\ea4\public\index.php(37): CodeIgniter\CodeIgniter->run()

The Home controller includes the following code snippet:

public function index()
{
    $session = session();
    $data = [];
    // Check for post
    if ($this->request->getMethod() === 'post') {
        // Validate the user input
        if (!($this->validate([
            'cmsuserEmail'      => ['label' => 'E-Mail',                'rules'   => 'required|min_length[6]|max_length[50]|valid_email'],
            'cmsuserPassword'   => ['label' => 'Κωδικός πρόσβασης',     'rules'   => 'required|min_length[8]|max_length[255]'],
        ]))) {
            // Validation has failed, redirect the user back
            return redirect()->to(base_url() . '/Backend/Home/index')->withInput();
        }
        $model = new CmsuserModel();
        $user = $model->where('cmsuserEmail', $this->request->getPost('cmsuserEmail'))->first();
        // If I try to var_dump user, var_dump is not displayed, if I print string "Debug" and die()  one line above, string is printed.

Steps to Reproduce

Also this https://preprocessor.space/questions/constant-mysqlistoreresult-is-not-defined-in-the-codeigniter-4-project-causing-an-error-in-the-mysqli-database

Expected Output

Does anyone know why this error is occurring? Do I need to define the constant MYSQLI_STORE_RESULT somewhere specific?

Anything else?

No response

@phpusrpro phpusrpro added the bug Verified issues on the current code behavior or pull requests that will fix them label Aug 28, 2024
@kenjis kenjis removed the bug Verified issues on the current code behavior or pull requests that will fix them label Aug 29, 2024
@kenjis
Copy link
Member

kenjis commented Aug 29, 2024

  1. Install and enable MySQLi extention
  2. Upgrade to the latest CI4. 4.1.5 has a lot of known vulnerabilities. See https://github.com/codeigniter4/CodeIgniter4/security/advisories

@kenjis
Copy link
Member

kenjis commented Aug 29, 2024

We use GitHub issues to track BUGS and to track approved DEVELOPMENT work packages. We use our forum to provide SUPPORT and to discuss FEATURE REQUESTS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants