Support » Fixing WordPress » Error establishing a database connection – frustrated

  • I get this message when I try to access my site.
    The site was working properly, and I tried to add google analytics…
    Anyway, sodabrasil was a site created out of WP. was WP.
    We did the integration of logins. Everything was working.
    When I run, it says it’s connected.
    this is the debug code.

    //connect to MySQL Server
    $conn = mysql_connect("localhost", "*****", "******");
    if (!$conn)
        echo "1. Successfully connected to MySQL database server.
    // select database
    $db_sel = mysql_select_db('houswe5_securelogin', $conn);
    if (!$db_sel)
        die ('cant\'t use database: ' . mysql_error());
        echo "2. WordPress database selected. ";

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    securelogin is the sodabrasil DB for the login.
    But accessing sodabrasil is blocked even before the login!!!

    I am not a professional coder, which makes things a lot harder.

    Thank you for you help.


Viewing 3 replies - 1 through 3 (of 3 total)
  • Just another piece of information: If you try to access the real config file, it throws the error message, with same credentials. The whole site, is down, not only the config file.

    ini_set("display_errors", 1);
    define('WP_USE_THEMES', false);
    //echo $_SERVER['DOCUMENT_ROOT'];
    global $mysqli;
    $server = 'localhost'; // The host you want to connect to.
    $username = '****'; // The database username.
    $password = '*****'; // The database password.
    $database = '*******'; // The database name.
    $dbms = 'MySQL 5';
    $dbport = '3306';
    //$dbh = mysql_connect($server, $username, $password) or die("Unable to connect to SQL server");
    //$my_db = @mysql_select_db($database) or die("Unable to select database");
    $mysqli = new mysqli($server, $username, $password, $database);
    //$mysqli = mysqli_connect($server, $username, $password, $database) or die("Error " . mysqli_error($link));
    if ($mysqli->connect_errno) {
        echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;die;
    // If you are connecting via TCP/IP rather than a UNIX socket remember to add the port number as a parameter.

    Thank you so much for any possible suggestion.

    That config file doesn’t look like a standard wordpress config file. I suggest looking for wp-config-sample in your wordpress folder and save it as wp-config.php and try that.

    That config file is for a site that was not WP origanally, but got login integrated to the blog …/blog (in my case …/paskin).
    This blog has standard config file, regular installation. And it’s working! It’s just the root (the original non WP site) that is not working. Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Error establishing a database connection – frustrated’ is closed to new replies.