I have been working from a modified database_api from the Mantis bug tracking development, trying to get Mantis to work with php 5 and Mysql 4.1.7.
I have downloaded a CVS version of this doc, but there is an error with the mysqli_escape_string.
Here is the total doc:
http://cvs.sourceforge.net/viewcvs.py/mantisbt/mantisbt/core/database_api.php?rev=1.36&view=markup
$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;
require_once( $t_core_dir . 'adodb/adodb.inc.php' );
$g_db = $db = ADONewConnection($g_db_type);
# An array in which all executed queries are stored. This is used for profiling
$g_queries_array = array();
# Stores whether a database connection was succesfully opened.
$g_db_connected = false;
# --------------------
# Make a connection to the database
function db_connect( $p_hostname, $p_username, $p_password, $p_database_name ) {
global $g_db_connected, $g_db;
$t_result = $g_db->Connect($p_hostname, $p_username, $p_password, $p_database_name );
if ( !$t_result ) {
db_error();
trigger_error( ERROR_DB_CONNECT_FAILED, ERROR );
return false;
}
$g_db_connected = true;
return true;
}
Then at the end of the doc:
function db_prepare_string( $p_string ) {
$t_db_type = config_get( 'db_type' );
switch( $t_db_type ) {
case 'mssql':
case 'odbc_mssql':
return addslashes( $p_string );
case 'mysql':
return mysql_escape_string( $p_string );
case 'mysqli':
return mysqli_escape_string( $p_string );
case 'postgres':
case 'postgres64':
case 'postgres7':
case 'pgsql':
return pg_escape_string( $p_string );
default:
error_parameters( 'db_type', $t_db_type );
trigger_error( ERROR_CONFIG_OPT_INVALID, ERROR );
}
}
But I get warnings for that saying "mysqli expects two parameters, 1 given"
Then I tried:
mysqli_escape_string($g_db, $p_string);
That gave an error message "mysqli expects parameters 1 to be mysqli, object given"
Then I tried:
mysqli_escape_string($g_db->$p_string);
And that didn't work.
Any ideas? I have upgraded to latest version of ADOdb which mantis uses. I have php 5.0.2 and MySQL 4.1.7.