Re: Call to undefined function mysql_real_escape_string()]

From: Date: Fri, 09 Dec 2005 05:08:10 +0000
Subject: Re: Call to undefined function mysql_real_escape_string()]
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-227168@lists.php.net to get a copy of this message
On Thu, Dec 08, 2005 at 08:32:56AM -0500, Paul Hickey wrote: > I have PHP compiled with mysqli. > > The standard answer from the Joomla forums is that I need to have > "mysql" vice "mysqli". I was looking for a more global solution than > having to modify the code for every component, module, mambot I want to > use. Well there is a rather global solution, but will require some work. You would have to create a wrapper for all mysql* calls to use mysqli, so for example: <?php if( !function_exists('mysql_connect') && function_exists('mysqli_real_connect') ) { function mysql_connect($server, $username, $password) { gobal $_mysql_mysqli_dbh_; $_mysql_mysqli_dbh_ = mysqli_init(); return mysqli_real_connect($_mysql_mysqli_dbh_, $server, $username, $password); } function mysql_real_escape_string($string, $dbh=false) { if($dbh === $false) { gobal $_mysql_mysqli_dbh_; $dbh = $_mysql_mysqli_dbh_; } return mysqli_real_escape_string($dbh, $string); } // any other interface needed. } ?> I've been meaning to write something like this for the Pear::PHP_Compat tool, it could help upgrading all your scripts to mysqli interface, not to mention upgrading to php5.1 Curt. -- cat .signature: No such file or directory

« previous php.general (#227168) next »