Ask coding questions

← Back to all posts
PHP and MySQLi
Lightcaster5 (14)

I don't know if it is simply disabled on or I am doing something wrong but I cannot connect to my SQL database through my PHP files. This is what I am currently doing:

$DB_SERVER = 'server_here';
$DB_USERNAME = 'username_here';
$DB_PASSWORD = 'password_here';
$DB_NAME = 'name_here';
// Check connection
if($mysqli === false){
    die("ERROR: Could not connect. " . $mysqli->connect_error);
} else {
  echo '<p>Connected</p>';

But whenever I run the page with the connection script I get the following error:

Uncaught Error: Class 'mysqli' not found in my-project-here

Answered by malvoliothegood (871) [earned 5 cycles]
View Answer
malvoliothegood (871)

Seems debatable whether you can do what you ask. Here is a comment I came across by Googling:

Lightcaster5 (14)

@malvoliothegood I don't believe you understand my post; I am asking whether or not it is possible and IF SO, what am I doing wrong/where can I go to learn how to achieve my goal?

malvoliothegood (871)

@Lightcaster5 I think I understood what you meant. My answer said I don't think you can do this and I included a link to an old conversation that basically said this. If you find an answer that lets you do such a hook up let me know. All the best.

Lightcaster5 (14)

@malvoliothegood Thanks, after a bit of testing and using echo phpInfo(); I've found that $pdo = new PDO(Stuff here); works but throws an exception because there are No Drivers Found and in phpInfo(); under the PDO section it says No Value for where it is saying if drivers are enabled. Thanks for the help!

malvoliothegood (871)

@Lightcaster5 Thanks for the info. You can easily develop using PHP, and MySql applications using the XAMPP, WAMP or LAMP packages. I have used the first two in the past and built a WordPress site locally before hosting it on the web. I have also used it to teach programming and relational databases when I was a teacher.