Skip to content

Instantly share code, notes, and snippets.

@j0uni
Created November 1, 2019 16:56
Show Gist options
  • Save j0uni/e06eebbca4cbba345f855d7571ac41f0 to your computer and use it in GitHub Desktop.
Save j0uni/e06eebbca4cbba345f855d7571ac41f0 to your computer and use it in GitHub Desktop.
IDIOT-PHP-DEVELOPERS - Fix mysql_connect etc. deprecated (with mysqli_connect and so-on..)
<?php
// include file for php called "IDIOT-PHP-DEVELOPERS"
// this file is a dirty fix to fix deprecated mysql_ - functions.
// first of all, I really don't understand why these functions needed to be deprecated.
// this decision by PHP developer has caused hundreds or thousands work hours to fix
// about this "library" : it might have not all functions so feel free to continue this work
// use as-you-wish, maybe share this file after if you enhanced it
// version history (please update too)
// version 1.0 - first version, written in five minutes to get my damn server working again
function mysql_connect($s,$u,$p)
{
global $server,$user,$pass;
$server=$s;
$user=$u;
$pass=$p;
}
function mysql_select_db($a)
{
global $server,$user,$pass;
global $dblink;
$dblink = mysqli_connect($server,$user,$pass,$a);
}
function split($a,$b)
{
return explode($a,$b);
}
function mysql_query($q)
{
global $dblink;
return mysqli_query($dblink,$q);
}
function mysql_fetch_array($a,$b)
{
global $dblink;
if ($b==MYSQL_ASSOC) $b=MYSQLI_ASSOC;
return $a->fetch_array($b);
}
function mysql_free_result($a)
{
global $dblink;
return mysqli_free_result($a);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment