Skip to content

Instantly share code, notes, and snippets.

@ismail0234
Created January 23, 2026 13:57
Show Gist options
  • Select an option

  • Save ismail0234/f97e3f72e3a285f27482f845a7566500 to your computer and use it in GitHub Desktop.

Select an option

Save ismail0234/f97e3f72e3a285f27482f845a7566500 to your computer and use it in GitHub Desktop.
mysql_query to mysqli_query
<?php
if (!function_exists('mysql_connect'))
{
$GLOBALS['dbConnection'] = null;
function mysql_connect($a, $b, $c, $d)
{
$GLOBALS['dbConnection'] = mysqli_connect($a, $b, $c, $d);
return $GLOBALS['dbConnection'];
}
function mysql_query($query, $conn = null)
{
if ($conn == null)
{
$conn = $GLOBALS['dbConnection'];
}
return mysqli_query($conn, $query);
}
function mysql_fetch_assoc($query)
{
return mysqli_fetch_assoc($query);
}
function mysql_fetch_array($query)
{
return mysqli_fetch_array($query);
}
function mysql_real_escape_string($param)
{
if(is_array($param))
return array_map(__METHOD__, $param);
if(!empty($param) && is_string($param)) {
return str_replace(array('\\', "\0", "\n", "\r", "'", '"', "\x1a"), array('\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'), $param);
}
return $param;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment