# mysql to mysqli wrapper-funcions for IIS

**URL:** <https://www.phphelp.com/t/mysql-to-mysqli-wrapper-funcions-for-iis/10016>\
**Category:** Code Snippets\
**Created:** [June 5, 2007, 4:39pm UTC](https://www.phphelp.com/t/mysql-to-mysqli-wrapper-funcions-for-iis/10016 "2007-06-05T16:39:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Q1712](https://www.phphelp.com/letter_avatar_proxy/v4/letter/q/a183cd/32.png) [@Q1712](https://www.phphelp.com/u/Q1712)\
**Post date:** [June 5, 2007, 4:39pm UTC](https://www.phphelp.com/t/mysql-to-mysqli-wrapper-funcions-for-iis/10016/1 "2007-06-05T16:39:05Z")

</div>

some IIS only have the mysqli-functions.  
put this at the top of your script:  
[php]  
if(!function\_exists(‘mysql\_connect’) and function\_exists(‘mysqli\_connect’))  
{  
define(‘MYSQL\_USE\_RESULT’,MYSQLI\_USE\_RESULT);  
define(‘MYSQL\_STORE\_RESULT’,MYSQLI\_STORE\_RESULT);  
define(‘MYSQL\_STORE\_RESULT’,MYSQLI\_STORE\_RESULT);  
define(‘MYSQL\_ASSOC’,MYSQLI\_ASSOC);  
define(‘MYSQL\_NUM’,MYSQLI\_NUM);  
define(‘MYSQL\_BOTH’,MYSQLI\_BOTH);

function mysql\_connect($p1,$p2,$p3)  
{  
return $GLOBALS[‘msqlilink’]=mysqli\_connect($p1,$p2,$p3);  
}  
function mysql\_select\_db($p1,$link=NULL)  
{  
if($link===NULL)$link=$GLOBALS[‘mysqlilink’];  
return mysqli\_select\_db($link,$p1);  
}  
function mysql\_query($p1,$p2=MYSQLI\_STORE\_RESULT,$link=NULL)  
{  
if($link===NULL)$link=$GLOBALS[‘mysqlilink’];  
return mysqli\_query($link,$p1);  
}  
function mysql\_fetch\_row($p1)  
{  
return mysqli\_fetch\_row($p1);  
}  
function mysql\_fetch\_array($p1,$p2=MYSQLI\_BOTH)  
{  
return mysqli\_fetch\_array($p1,$p2);  
}  
function mysql\_fetch\_assoc($p1)  
{  
return mysqli\_fetch\_assoc($p1);  
}  
function mysql\_insert\_id($link=NULL)  
{  
if($link===NULL)$link=$GLOBALS[‘mysqlilink’];  
return mysqli\_insert\_id($link);  
}  
function mysql\_info($link=NULL)  
{  
if($link===NULL)$link=$GLOBALS[‘mysqlilink’];  
return mysqli\_info($link);  
}  
function mysql\_affected\_rows($link=NULL)  
{  
if($link===NULL)$link=$GLOBALS[‘mysqlilink’];  
return mysqli\_affected\_rows($link);  
}  
function mysql\_errno($link=NULL)  
{  
if($link===NULL)$link=$GLOBALS[‘mysqlilink’];  
return mysqli\_errno($link);  
}  
function mysql\_error($link=NULL)  
{  
if($link===NULL)$link=$GLOBALS[‘mysqlilink’];  
return mysqli\_error($link);  
}  
function mysql\_close($link=NULL)  
{  
if($link===NULL)$link=$GLOBALS[‘mysqlilink’];  
return mysqli\_close($link);  
}  
function mysql\_escape\_string($p1,$link=NULL)  
{  
if($link===NULL)$link=$GLOBALS[‘mysqlilink’];  
return mysqli\_real\_escape\_string($link,$p1);  
}  
}  
[/php]
