PHP7可以';t连接到MySQL

PHP7可以';t连接到MySQL,mysql,php-7,Mysql,Php 7,下面的代码已经在PHP5和MySQL5.6上运行。在Kubuntu和窗户下。在本例中,我尝试在Kubuntu 16.04 PHP7和MySQL5.7下运行它。无法建立到数据库的连接。没有错误消息,执行以连接到base的行结束,因此,代码中的report\u before被键入,而report\u after则不被键入 <?php echo "<form id='login' action='' method='POST' accept-charset='UTF-8'>"; e

下面的代码已经在PHP5和MySQL5.6上运行。在Kubuntu和窗户下。在本例中,我尝试在Kubuntu 16.04 PHP7和MySQL5.7下运行它。无法建立到数据库的连接。没有错误消息,执行以连接到base的行结束,因此,代码中的report\u before被键入,而report\u after则不被键入

<?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');
        }
    } 
问题在这里:

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

从PHP5.5.0开始,此扩展已被弃用,并已作为 PHP7.0.0的应用

使用mysqli,几乎相同,但您必须升级所有代码