Skip to content
Sign upLog in
← Back to Community
PHP and MySQLi
Profile icon
Lightcaster5

I don't know if it is simply disabled on repl.it 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'; $mysqli = new mysqli(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME); // 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

Voters
Profile icon
Rosamaria01
Profile icon
Loshad
Profile icon
charliekmcmahon
Profile icon
DiscordOdysseyD
Profile icon
Lightcaster5
Comments
hotnewtop
Profile icon
[deleted]

Seems debatable whether you can do what you ask. Here is a comment I came across by Googling: https://repl.it/talk/ask/How-do-I-use-a-database-with-the-new-php-server/15708

Profile icon
Lightcaster5

@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?

Profile icon
[deleted]

@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.

Profile icon
Lightcaster5

@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!

Profile icon
[deleted]

@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.