Bug #17455
closedNo proper error message mysql_error() information needed
0%
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)
Updated by Martin Kutschker over 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.
Updated by Martin Kutschker over 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.
Updated by Martin Kutschker over 17 years ago
Fixed in SVN (trunk and TYPO3_4-1).