CodeIgniter Forums
mysqli_sql_exception No such file or directory - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: mysqli_sql_exception No such file or directory (/showthread.php?tid=76098)

Pages: 1 2


mysqli_sql_exception No such file or directory - GamalAbomera - 04-14-2020

I just started learning codeigniter 4 and faced this problem. I searched a lot and tried some solutions but it is of no use
I am using Ubuntu
[problem : ]
mysqli_sql_exception No such file or directory


RE: mysqli_sql_exception No such file or directory - jreklund - 04-14-2020

There can be a couple of things. A miss/match against your PHP and MySQL version. Or you simply don't have mysqli installed.


RE: mysqli_sql_exception No such file or directory - GamalAbomera - 04-14-2020

(04-14-2020, 09:13 AM)jreklund Wrote: There can be a couple of things. A miss/match against your PHP and MySQL version. Or you simply don't have mysqli installed.


php ver 7.2

mysql ver  10.1.30-MariaDB (with xampp) 

and i have mysqli


RE: mysqli_sql_exception No such file or directory - jreklund - 04-14-2020

How do you connect to your database? Those should be compatible.


RE: mysqli_sql_exception No such file or directory - GamalAbomera - 04-14-2020

(04-14-2020, 11:02 AM)jreklund Wrote: How do you connect to your database? Those should be compatible.

By .env

And on other prject by app/config/database.php


RE: mysqli_sql_exception No such file or directory - jreklund - 04-14-2020

Can you show the code? Just remove the password of course.
Does it instantly die or when you do anything specific?


RE: mysqli_sql_exception No such file or directory - GamalAbomera - 04-14-2020

(04-14-2020, 11:37 AM)jreklund Wrote: Can you show the code? Just remove the password of course.
Does it instantly die or when you do anything specific?

it's simple code

controler
PHP Code:
<?php namespace App\Controllers;
use 
CodeIgniter\Controller;
use 
App\Models\NewsModel;


class 
News extends Controller{
    public function index()
    {
        $model = new NewsModel();
        $data['news'] = $model->findAll();
        echo view('template/all',$data);
    }
    public function show($slug null)
    {
        $model = new NewsModel();
        $db = \Config\Database::connect();
        // $data['news'] = $model->where(['slug'=> $slug])->first();
        $query $db->query('SELECT * FROM news');
        $results $query->getResult();

        $data['news'] = $results;

        echo view('template/show',$data);
    }



model

PHP Code:
<?php

namespace App\Models;

use 
CodeIgniter\Model;

class 
NewsModel extends Model
{
    protected $table 'news';


view

PHP Code:
<!DOCTYPE html>
<
html lang="en">

<
head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>All News</title>
</
head>

<
body>
    <?php
    
if (!empty($news)) {
        foreach ($news as $news_item) {
    ?>
            <div>
                <h4> <?php echo $news_item['title'?> </h4>
                <p> <?php echo $news_item['body'?> </p>
            </div>
        <?php
        
}
    } else {
        ?>
        <h3>No News</h3>

        <p>Unable to find any news for you.</p>
    <?php
    
}
    ?>
</body>

</html> 



RE: mysqli_sql_exception No such file or directory - GamalAbomera - 04-15-2020

help me please


RE: mysqli_sql_exception No such file or directory - GamalAbomera - 04-15-2020

i found the Solution
codeigniter 4 don't working with xampp apache and mysql
but when i installed apache2 and mysql without xampp
everythings are worked successfully


RE: mysqli_sql_exception No such file or directory - manendraverma - 04-26-2020

(04-15-2020, 03:07 AM)GamalAbomera Wrote: i found the Solution
codeigniter 4 don't working with xampp apache and mysql
but when i installed apache2 and mysql without xampp
everythings are worked successfully

I was also facing same issue and try different trick to fix but not working. You can believe there is very easy solution to solve this which i've applied. You just need to change host 'localhost' to '127.0.0.1' and go ahead.