0

Error
Database connect failed

Warning: mysql_error() expects parameter 1 to be resource, null given in /home/globilla/public_html/inc/classes/BxDolDb.php on line 447

Fatal error: Call to a member function getParam() on a non-object in /home/xyz/public_html/include/db.inc.php on line 83


please help me to sort out this problem.

3
Contributors
10
Replies
11
Views
6 Years
Discussion Span
Last Post by smantscheff
0

Could you provide us with the part of code which is supposedly having the problem please? We will be able to help a lot more if you could. Censor any passwords within the code and anything else that you don't want us seeing.

0
line82    function getParam( $param_name, $use_cache = true ) {
line83    return $GLOBALS['MySQL']->getParam($param_name, $use_cache);
line84    }

[full file Code]

require_once("header.inc.php");
require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );
require_once( BX_DIRECTORY_PATH_CLASSES . 'BxDolDb.php' );

$GLOBALS['MySQL'] = new BxDolDb();

$site['title'] = getParam('site_title');
$site['email'] = getParam('site_email');
$site['email_notify'] = getParam('site_email_notify');

function db_list_tables( $error_checking = true ) {
    $GLOBALS['MySQL']->setErrorChecking ($error_checking);
    return $GLOBALS['MySQL']->listTables();
}

function db_get_encoding ( $error_checking = true ) {
    $GLOBALS['MySQL']->setErrorChecking ($error_checking);
    return $GLOBALS['MySQL']->getEncoding();
}

function db_res( $query, $error_checking = true ) {
    $GLOBALS['MySQL']->setErrorChecking ($error_checking);
    return $GLOBALS['MySQL']->res($query);
}

function db_last_id() {
    return $GLOBALS['MySQL']->lastId();
}

function db_affected_rows() {
    return $GLOBALS['MySQL']->getAffectedRows();
}

function db_res_assoc_arr( $query, $error_checking = true ) {
    $GLOBALS['MySQL']->setErrorChecking ($error_checking);
    return $GLOBALS['MySQL']->getAll($query);
}

function db_arr( $query, $error_checking = true ) {
    $GLOBALS['MySQL']->setErrorChecking ($error_checking);
    return $GLOBALS['MySQL']->getRow($query, MYSQL_BOTH);
}

function db_assoc_arr( $query, $error_checking = true ) {
    $GLOBALS['MySQL']->setErrorChecking ($error_checking);
    return $GLOBALS['MySQL']->getRow($query);
}

function db_value( $query, $error_checking = true, $index = 0 ) {
    $GLOBALS['MySQL']->setErrorChecking ($error_checking);
    return $GLOBALS['MySQL']->getOne($query, $index);
}

function fill_array( $res ) {
    return $GLOBALS['MySQL']->fillArray($res, MYSQL_BOTH);
}

function fill_assoc_array( $res ) {
    return $GLOBALS['MySQL']->fillArray($res, MYSQL_ASSOC);
}

[B]function getParam( $param_name, $use_cache = true ) {
    return $GLOBALS['MySQL']->getParam($param_name, $use_cache);
}[/B]

function getParamDesc( $param_name ) {
    return $GLOBALS['MySQL']->getOne ("SELECT `desc` FROM `sys_options` WHERE `Name` = '$param_name'");
}

function setParam( $param_name, $param_val ) {
    return $GLOBALS['MySQL']->setParam($param_name, $param_val);
}

Edited by Reverend Jim: Fixed formatting

0

$GLOBALS is obviously not an object.
It should have been created by $GLOBALS = new BxDolDb();
This seems to have failed.
Try to connect using the standard MySQL client from the command line with the same parameters as coded somewhere in your included scripts.
This might be a compatibility issue between old and new style passwords. Cf. http://dev.mysql.com/doc/refman/5.1/en/old-client.html

0

it was working fine, i did nothing with the code, its happening after up gradation of server by hosting service providers, i used the same code on free hosting and local server as well, it is working fine, i told to hosting providers and showed the free hosting link where i uploaded the same code but they still think that error is in code. what you say?

0

Is the database configured for connections from outside?
If so, try to connect from a mysql command line client using the connection parameters from your php scripts.
If not, use a PHP test script like this: <?php if (!mysql_connect(SERVER,USER,PASSWORD)) echo mysql_error(); ?> Try to debug only the connection issue, nothing else.

0

Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 11176288 bytes) in /home/jiggi/public_html/inc/utils.inc.php on line 236

0

You are still using code which you do not control (or did you out-comment 235 of those 236 lines in utils.inc.php?).
Solve one problem at a time.
Write a one-line PHP script with your connection statement and test it.

0

Put a debug output line before the connection statement in your library to check if it uses the same parameters which you entered in your test script.
Maybe you redefined some constant -?
Also insert a debug_backtrace() in your code where it returns the mysql_error().

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.