2

The following code had worked on PHP5 and MySQL5.6. Under Kubuntu and Windows. In this particular case I'm trying to run it under Kubuntu 16.04 PHP7 and MySQL5.7. Connection to database can not be established. There is no error message, the execution ends with the row for connection to base, and as a result report_before from the code is typed, but report_after is not.

<?php

echo "<form id='login' action='' method='POST' accept-charset='UTF-8'>";
echo "<input type='password' name='password' id='password' maxlength='50'>";
echo "<input type='submit' name='OK' value='OK'>";

if (isset($_POST["password"]))
{
    if($_POST["password"] == '1234')
    {
        echo "rep_before";
        $link = mysql_connect('localhost:3306', 'acs', 'sesame');
        echo "rep_after;
        if ($link) 
        {
            session_start();
            header('Location: main_page.php');
        }
    } 

}

Kati Avramova
  • 61
  • 2
  • 4

1 Answers1

4

Problem is here :

 $link = mysql_connect('localhost:3306', 'acs', 'sesame');

http://php.net/manual/en/intro.mysql.php

This extension is deprecated as of PHP 5.5.0, and has been removed as of PHP 7.0.0.

use mysqli, almost the same but you will have to upgrade all your code.

Louis Loudog Trottier
  • 1,367
  • 13
  • 26