PHP4/5 and MySQL

wolf

New Member
Hello again
I am using an Apache Hosting Service with a cPanel access. I installed MLM on PHP4 and a MySQL 5.1.52. That works well, as soon as I switch to PHP5 the MySQL connection fails. I would need PHP5 for another script.
Any idea ?
 

stanbusk

Administrator
Staff member
MLM is being developed with PHP5 actually. Anyway the way to connect to a mySQL server is the same for PHP4 and PHP5.
 

wolf

New Member
I checked with Hostgator today for 30 minutes and they concluded that its a coding error.
Thats their answer : There is no server error being hit the reason it is blank or [] as well is because there is no echo in the coding to label the error so you will need to speak to the developers please.

Again, everything is find with PHP4. Weird ....

I forgot to mention that I downloaded the latest version of MLM.

If I try to create a new in the browser the error message is : Error - Server problem when reading list. [: ]
 

stanbusk

Administrator
Staff member
The function used to connect to the mySQL server is called 'ConnectToMySqlServer()'. You will find it in 'lm_functions.php', line 1809 to 1822. We use the only function available in PHP to do that, it is called mysql_connect. It is a PHP 4/5 function. The heading '@' is for avoiding getting the error on the http console. You can play with that function and see where it fails for you but to say the thru, in 3 years I have never seen any problem related to it.

You can even send debugging messages to yourself modifying the function this way:

Code:
// Connect to the mySQL server
function ConnectToMySqlServer() {
	global $dbhost, $dbusername, $dbuserpass, $dbname, $mysql_link, $mysql_err, $mysql_charset, $admin_address;
	if ( !$mysql_link ) { $mysql_link = @mysql_connect ( $dbhost, $dbusername, $dbuserpass, $dbname ); }
	if ( !$mysql_link ) {
		$mysql_err = @mysql_errno( $mysql_link ) . ": " . @mysql_error( $mysql_link );
		@mail( $admin_err_addr, "[ConnectToMySqlServer] Impossible to connect to server", $mysql_err, $headers, "-f$admin_address" );
		return false;
	} else {
		$version = GetmySQLFullVersion();
		//if ( $version[0] >= 5 && $version[1] >= 2 && $version[2] >= 3 ) { @mysql_set_charset( "utf8", $mysql_link ); }
		if ( function_exists( "mysql_set_charset" ) ) { @mysql_set_charset( "utf8", $mysql_link ); }
		$mysql_charset = @mysql_client_encoding( $mysql_link ); // Success?
		return true;
	}
}

That modified code will send an email to you if the connection fails with the exact error.
 
Top