我正在尝试连接到数据库,但它无法正常工作,我不明白为什么

时间:2018-01-30 22:05:23

标签: php html mysql

我正在学习php和mysql,我一直遇到这个问题。这是我的代码

    <?php

    $username = $_POST['username'];
    $password = $_POST['password'];


   msql_connect("localhost","!userName!","!password!");

     msql_select_db("!dataBase!");


?>
<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" type="text/css" href="forum-style.css">
    <script type="text/javascript" href="forum-script.js"></script>
    <title>Spread</title>
        </head>

<body>
    <form method="post">

        <input name="username" id="form-username1" placeholder="username">

        <input name="password" id="form-password1" placeholder="password">

        <input type="submit" value="Log in">



    </form>

    <p>Welcome to Spreads official testing platform. If you encounter any bugs, please click
    the "report bug" button.</p>



</body>

我的java脚本文件和样式文件中没有任何内容。这是我的错误消息,它显示在我的页面index.php上(代码附带的那个:)

Fatal error: Call to undefined function msql_connect() in /home3/notSureIfIShouldShowThis/public_html/spread/index.php on line 7

我的数据库被调用!dataBase !,用户是!userName !,密码是!密码!,它是由hostgator托管所以本地主机:3(我显然只是为了安全而将其改为这些名称)

2 个答案:

答案 0 :(得分:1)

mSql包需要编译成你的php版本。 http://php.net/manual/en/msql.installation.php

答案 1 :(得分:-2)

如果使用PHP&lt;

,则必须使用mysql_connect。 7.0和mysqli_connect,如果您的PHP版本大于7.0