XAMPP: From MySQL to MariaDB

KMatle

Expert
Licensed User
Longtime User
I use XAMPP for my php & MySQL environment. Newer releases of XMAPP (= new versions of php, security fixes, etc.) come with MariaDB instead of MySQL.

Today I've done a fresh install of the newest XAMPP & MariaDB package to see if my php-db scripts still run. Of course not. But the changes are minimal:

This

B4X:
$host = "127.0.0.1";
$user = "******";
$pw = "***********";
$db = "mydb";

$con = mysql_connect($host,$user,$pw) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET NAMES 'utf8'");

fails and has to be replaced by this:

B4X:
$con = mysqli_connect($host,$user,$pw) or die(mysqli_error());
mysqli_select_db($con, $db) or die(mysqli_error());
mysqli_query($con, "SET CHARACTER SET utf8");
mysqli_query($con, "SET NAMES 'utf8'");

...

$q = mysqli_query($con,"SELECT PrivKey FROM rsakeys Where xxx = 'yyy'") or die(mysqli_error());

1. At every command they added an "i" (mysql_select -> mysqli_select)
2. Commands have one more parameter: $con

With a "change all" it's easy to change. Dumping db's and importing use the same names so no change is needed.
 

sorex

Expert
Licensed User
Longtime User
I hope providers keep installing the legacy stuff when updating their php stuff or a lot of sites will go down soon due to the missing mysql commands.
 
Top