The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

Error establishing a database connection - frustrated (4 posts)

  1. Gloak
    Posted 2 years ago #

    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.
    sodabrasil.com/paskin was WP.
    We did the integration of logins. Everything was working.
    When I run http://sodabrasil.com/dbtest.php, 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.


  2. Gloak
    Posted 2 years ago #

    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, sodobrasil.com 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.

  3. Bloke
    Posted 2 years ago #

    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.

  4. Gloak
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic