Suddenly and without having changed anything, website went blank!

Suddenly and without having changed anything on my part, a few weeks ago my website went blank!!!

It’s a PHP website, very simple with just 2 pages, but it’s also very important because it shows the results of DNA tests.
Help me please.

When I open the Network tab in the Developer Tools in my browser and refresh the page, I see the page returns with the status code 500. That usually means the PHP code has crashed.

There are many different ways in which PHP code could crash, so you’ll need to do some investigation as to why your site is not working. This article provides some useful steps to get started:


Thank you very much Admin.

I turned on errors in the control panel and it seems that the problem is in MySQL connection functions in this bit of PHP code:

//1. Create database connection
$connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS);
@mysql_query('SET NAMES "utf8"');
@mysql_query('SET CHARACTER SET utf8');
@mysql_query('SET COLLATION_CONNECTION = "utf8_general_ci"');
if (!$connection) {
die("Ops! Database connection FAILED-1: " . mysql_error());
//2. Select database
$db_select = mysql_select_db(DB_NAME, $connection);
if (!$db_select){
die("Ops! Database selection failed: " . mysql_error());

Can you please help me to replace the code of disabled functions in this latest version of PHP you installed?


Hi Cferreira,

This is normally your duty, but since you asked nicely and have attempted to give a formatted version, here’s the deed, enjoy!


//1. Create database connection
$connection = mysqli_connect(DB_SERVER, DB_USER, DB_PASS);
mysqli_query($connection, 'SET NAMES "utf8"');
mysqli_query($connection, 'SET CHARACTER SET utf8');
mysqli_query($connection, 'SET COLLATION_CONNECTION = "utf8_general_ci"');
if (!$connection) {
    die('Ops! Database connection FAILED-1: ' . mysqli_error($connection));

//2. Select database
$db_select = mysqli_select_db($connection, DB_NAME);
if (!$db_select) {
    die('Ops! Database selection failed: ' . mysqli_error($connection));

I’m not going to rewrite your entire code for you. It’s your code and your responsibility to fix.

But for the most part, it’s not that difficult.

You can start by just doing a search-replace across your code and replace mysql_ with mysqli_. Your code will be 90% correct with that simple change.

The remaining 10% will need to be fixed by hand. This includes the mysql_select_db for example, that function does not have a MySQLi counterpart, and you just specify the database as part of the mysqli_connect function.

Fortunately, you’re far from the first person to have to do this, so there are plenty of guides online. I did a quick look at this one seems quite comprehensive to me:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.