Could not connect: error HELP!

Hi, I face this error after i manage to settle all other errors related to db. can advice?
https://acomtest.000webhostapp.com/index.html

Using PDO
Make a test file and use the same credentials to ensure the connection is working

hi. it solved after i change back the server connection from 127.0.0.1 to localhost (read from other post). thanks for the guides. it helps to understand more. all the connections are success but now not able to send the input data into database. arghh… already created new table and tested. still not able to store data into database. can u help that?

Hi,

My site has successfully established all the correct connection to database etc. But when i enter data into my form. it will not insert into database. working fine at my localhost , only issue here. already try change to mysqli for php 7.1 n now downgraded back to php 5.2 using mysql.

If i type data manually in database, it will appear in the screen. Can u help with that?

https://acomtest.000webhostapp.com/index.html

code:

<?php $con=mysql_connect("localhost","id10087674_svr","pwd"); if(!$con) { die('Could not connect: '.mysql_error()); } mysql_close($con); ?>

// adding to DB table posted message
function acceptMessages() {
if ($_COOKIE[‘member_name’]) {
if(isset($_POST[‘s_say’]) && $_POST[‘s_message’]) {
$sUsername = $_COOKIE[‘member_name’];

            //the host, name, and password for your mysql
            $vLink = mysql_connect("localhost", $this->sDbUser, $this->sDbPass);

            //select the database
            mysql_select_db($this->sDbName);

            $sMessage = mysql_real_escape_string($_POST['s_message']);
            if ($sMessage != '') {
                mysql_query("INSERT INTO `s_chat_messages4` SET `user`='{$sUsername}', `message`='{$sMessage}'"); //, `time`=UNIX_TIMESTAMP()");
            }

            mysql_close($vLink);
        }
    }

    ob_start();
    require_once('chat_input.php');
    $sShoutboxForm = ob_get_clean();

    return $sShoutboxForm;
}

function getMessages() {
$vLink = mysql_connect(“localhost”, $this->sDbUser, $this->sDbPass);

    //select the database
    mysql_select_db($this->sDbName);

    //returning the last 15 messages
    $vRes = mysql_query("SELECT * FROM `s_chat_messages4` ORDER BY `id` ASC");

    $sMessages = '';

    // collecting list of messages
    if ($vRes) {
        while($aMessages = mysql_fetch_array($vRes)) {
            //$sWhen = date("H:i:s", $aMessages['time']);
            $sMessages .= '<div class="message">' . '<span style="font-weight:bold; font-size:18px; color:black;">' .$aMessages['user'] . ': ' . '</span>'. $aMessages['message'] . '<span> </div>' . '<br/>'; //(' . $sWhen . ')</span></div>' . '<br/>';
		}
	}
    else {
        $sMessages = 'DB error, create SQL table before';
	}
    mysql_close($vLink);

    ob_start();
    require_once('chat_begin.php');
    echo $sMessages;
    require_once('chat_end.php');
    return ob_get_clean();
}