0

Host updated the environment to PHP 7. Had to update db.php and added the following:

<?php
include('administrator/configuration.php');

//echo DATABASE;
//mysql_select_db(DATABASE, mysql_connect(HOSTNAME, DBUSER, DBPASS));
$con = mysqli_connect(HOSTNAME, DBUSER, DBPASS, DATABASE) or die("Error message...");

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}


if (!$con) {
     "Error: Unable to connect to MySQL." . PHP_EOL;
    echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
    echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
    exit;
}

printf ("Success: A proper connection to MySQL was made! The ???? database is great." . PHP_EOL);
printf("Host information: " . mysqli_get_host_info($con) . PHP_EOL);


echo "<p><hr />";


try {
    //$query = sprintf("SELECT database() AS the_db");
    $query = sprintf("SELECT COUNT(*) FROM albums");



    /* return name of current default database */
    if ($result = mysqli_query($con, $query)) {
        $row = mysqli_fetch_row($result);

        //printf("Default database is %s.\n", $row[0]);
        printf($row[0]);
    }
    //throw new Exception();
} catch (Exception $e) {
    print "Something went wrong /n" . $e;
} finally {
   // do nothing 
}

?>

As per How to change mysql to mysqli? , I tried making the change mysql_query( -> mysqli_query($con, .

Navigating to ~/administrator/login.php results in a blank page. I edited ~/public_html/administrator/lib/connection.php - with the above change, nothing.

I'm guessing a WordPress upgrade to start then take it from there.

Any other suggestions?

ElHaix
  • 12,846
  • 27
  • 115
  • 203
  • do you have display errors enabled? – Clint Sep 04 '19 at 02:30
  • we can only guess on our end. try to be on our shoes, how are we going to figure out what "blank page" means. check out error log – Kevin Sep 04 '19 at 02:39
  • You need to remove the COUNT() function and just select the column(s) themselves. That's what I think is wrong here. If you're going to want to keep that aggregate function, you're going to have to use an alias and change the array to that name to echo it out. – Funk Forty Niner Sep 04 '19 at 02:54
  • @Funk, they are using fetch_row, so with the numerical index there is no need for an alias – Your Common Sense Sep 04 '19 at 04:38
  • This count test W's just to ensure the db calls were working with the established connection. That's all. That's established. So maybe do a full upgrade on WordPress? Is there a plugin to fix mysql to mysqli? – ElHaix Sep 04 '19 at 12:54
  • @YourCommonSense Oh I see. I stand corrected then; thanks. I thought for sure that COUNT() was the issue. – Funk Forty Niner Sep 04 '19 at 14:27

0 Answers0