Ask coding questions

← Back to all posts
How to connect to an external mysql database?
baciotti (13)

I am trying to connect to mysql using php but the function is not working. I am receiving this error:

Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in /home/runner/conexao.php:7 Stack trace: #0 /home/runner/carro_insert.php(6): include() #1 {main} thrown in /home/runner/conexao.php on line 7

<?php $servername = "sql10.freesqldatabase.com"; $database = "sss"; $username="ssss"; $password="ssss"; $conexao=mysqli_connect($servername, $username, $password, $database); ?>
Comments
hotnewtop
RonaldSchildge (2)

Has there been any help on how to enable the mysqli extension?

Liubov5 (0)

@baciotti did you get an answer?

matjung (0)

While you cannot edit php.ini, you can create your own php.ini.
Copy the driver into a ext directory

php -c php.ini -i | grep mysql

MysqlI Support => enabled
Client API library version => mysqlnd 5.0.12-dev - 20150407 - $Id: 38fea24
f2847fa7519001be390c98ae0acafe387 $
Active Persistent Links => 0
Inactive Persistent Links => 0
Active Links => 0

Then php with mysql code works if the sql server is located at another host.
Instructions for getting the drivers:
https://repl.it/talk/learn/Installing-WordPress-on-Replit/34284

Mr4FX (0)

repl.it should allow users to edit PHP.ini
!! other ways repl.it will be closed source for coders

LuukDev (0)

This is a problem by Repl.it, they didn't install the MySQLi extension what allows you to use a database.