skip to Main Content

My question is just similar to this question but I am using PHP version 7.4.1 in Windows 7 [32bit].

<?php
if(!function_exists('mysqli_init') && !extension_loaded('mysqli')){
        echo 'We dont have mysqli'; 
    }
    else{
        echo'Yes';
    }
    mysqli_connect('localhost', "root", "", "akash");
?>

It returns:

We dont have mysqli

Fatal error: Uncaught Error: Call to undefinedfunction mysqli_connect()

What I have tried:

As I have seen various answers on this problem and all the answers is simply based on the php.inf file but in my php directory there is no file of this name and so after looking on how to install this I couldn’t really find a way, after visiting http://php.net/manual/en/mysqli.installation.php, I scrolled down to find the "PHP 5.3.0 and newer" section where it says I wouldn’t need to worry about installing it.

2

Answers


  1. First you need to have a php.ini somewhere.

    Usually in the directory with php you have two files php.ini-development and php.ini-production – they are examples of php.ini with some recommended settings.

    1. Copy php.ini-development into php.ini and place it somewhere.

    2. Find the line

    ;extension=mysqli
    

    and uncomment it (remove the semicolon from the beggining)

    1. Run your server. If php.ini is placed not where php.exe is, then pass the path to it in the command line after -c option:
    D:pathtophpphp.exe -S localhost:8080 -c D:pathtoinifilephp.ini ...
    
    Login or Signup to reply.
  2. If you host the server yourself, in the php.ini file remove the semicolon in front of the extension extension=php_mysqli.dll

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search