How to enable mysqli in PHP in Windows


I was trying to run a SQL query in PHP. I was using mysqli command to connect to the database to retrieve data.

However, I ran into an error while loading the PHP file as –

Fatal error: Uncaught Error: Class 'mysqli' not found

This is how I solved it…

This error will appears if ‘mysqli’ is not installed in your local machine running on Windows.

To install ‘mysqli’ in PHP in Windows machine, follow these steps.

  1. Check your environment variables to find out your php installation directory
  2. Go to the directory where you had installed PHP.
  3. Locate the php.ini file.
  4. Open the php.ini file try to locate a line titled “;extension=mysqli”.
  5. By default it will appear as disabled or commented out. You can enable it by removing the semicolon.
  6. Change the line to “extension=mysql”, save and close the file.
  7. Restart your PHP server and start running your SQLI commands in PHP.

I hope you will find this post helpful.

Follow Me on Social Media

Advertisement
FREE Sales CRM Software

Fully customizable CRM Software for Freelancers and Small Businesses

Signup for Free

Sign up for DigitalOcean Cloud

Get FREE $200 credits, deploy your hobby projects for Free

DigitalOcean Referral Badge
Sign up for Hostinger Cloud or VPS plans and get upto 20% Discount