Project

General

Profile

Actions

Bug #17455

closed

No proper error message mysql_error() information needed

Added by Christoph Eisenmann almost 17 years ago. Updated almost 16 years ago.

Status:
Closed
Priority:
Should have
Category:
Database API (Doctrine DBAL)
Target version:
-
Start date:
2007-07-10
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.1
PHP Version:
4.3
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

function sql_pconnect in class class.t3lib_db.php

if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['no_pconnect']) {
$this->link = @mysql_connect($TYPO3_db_host, $TYPO3_db_username, $TYPO3_db_password);
} else {
$this->link = @mysql_pconnect($TYPO3_db_host, $TYPO3_db_username, $TYPO3_db_password);
}

I personally think this is not a good idea... The mysql error message should be passed back and displayed....

I spent hours until I found this function in the source. Disabling the @ and the problem was fixed within no time... It was no user , password , database problem but a problem in the mysql driver which caused my problem. With no good information a person who wants to installl typo3 is pretty much lost with this kind of code. Better information should be given to the poor guy who is installing typo3.

something like this is needed....

if (mysql_error()) echo "Error " . mysql_error();

Please do not forget... Some people use Typo3 3 volentarly... Some are forced by their bosses to use it....
(issue imported from #M5941)

Actions #1

Updated by Martin Kutschker almost 17 years ago

The problem is that mysql_error() requires a link. Try this scenario:

$conn = @mysql_connect("validhost","user","pwd");
mysql_query("blah");
@mysql_connect("a","b","c");
echo mysql_error();

You will see that the message will return the query error and not the connection error.

Actions #2

Updated by Martin Kutschker almost 17 years ago

Solution:

ini_set("track_errors",1);
$conn = @mysql_connect("invalidhost","user","pwd");
if (!$conn) {
$err = $php_errormsg;
}
ini_restore("track_errors");

BTW, the connection failure is already logged.

Actions #3

Updated by Martin Kutschker almost 17 years ago

Fixed in SVN (trunk and TYPO3_4-1).

Actions

Also available in: Atom PDF