0

I have php7 installed and working

I'm using the Built-in HTTP server

Uncommented "extension_dir="C:\php\ext" and extension="php_mysqli.dll" in the php.ini files development and production (did production too just to be safe)

When I used the phpinfo() method, I found that it says "Loaded Configuration file: none"

I've installed php7 therefore mysqli is supposed to already be installed. Looking online I found that you have to edit the php.ini file (mentioned how I did so in bullet points above) however when I run:

$servername = "localhost";
$username = "username";
$password = "password";

// Create connection
$conn = new mysqli($servername, $username, $password);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>

I get the error:

Fatal error: Uncaught Error: Class 'mysqli' not found in C:\Users\Calvin\try\learningMySQL.php:17 Stack trace: #0 {main} thrown in C:\Users\Calvin\try\learningMySQL.php on line 17

Thank you, any help is appreciated.

Shadow
  • 33,525
  • 10
  • 51
  • 64

1 Answers1

-3
$servername = "localhost";
$username = "username";
$password = "password";
$database = "database";

$con = mysqli_connect("$servername","$username","$password","$database");
    if (mysqli_connect_errno()){
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
  • 1
    I doubt this would work because `mysqli` and `mysqli_connect` are from the same package. Give this a quick read; [Difference between mysqli and mysqli_connect](https://stackoverflow.com/questions/15707696/new-mysqli-vs-mysqli-connect) – IsThisJavascript Jul 08 '19 at 12:03
  • `mysqli` also work `$conn = new mysqli($servername, $username, $password, $dbname);` – mehul bhanderi Jul 08 '19 at 12:05
  • Brother, his problem is that `mysqli` is not registed as a module, so I don't think it would. `new mysqli` is what he has already :) – IsThisJavascript Jul 08 '19 at 12:06