Php 我收到连接被拒绝访问的警告

Php 我收到连接被拒绝访问的警告,php,connection,database-connection,Php,Connection,Database Connection,我的连接有问题。这是一个共享服务器,我已经使用SSH检查了我的数据库和表。 我使用相同的凭证通过web访问它们。然而,它给了我错误。我检查是否有输入错误,但它们是正确的,我的sql access和数据库没有用户名或密码。因此,我的主机只有一个用户和密码。我已经创建了我的选项卡,并使用相同的用户名和密码将我的页面上载到同一个数据库 #这个问题可能是服务器问题吗?所以不管是谁建立的都没有正确配置它# 这就是错误: 警告:mysql_connect():第10行的/home/cop…/homepage

我的连接有问题。这是一个共享服务器,我已经使用SSH检查了我的数据库和表。 我使用相同的凭证通过web访问它们。然而,它给了我错误。我检查是否有输入错误,但它们是正确的,我的sql access和数据库没有用户名或密码。因此,我的主机只有一个用户和密码。我已经创建了我的选项卡,并使用相同的用户名和密码将我的页面上载到同一个数据库


#这个问题可能是服务器问题吗?所以不管是谁建立的都没有正确配置它#

这就是错误:

警告:mysql_connect():第10行的/home/cop…/homepage/login.php中的用户'cop…'@'139.62.63…(使用密码:YES)的访问被拒绝 无法连接到数据库

这是我的代码,我能做些什么吗?除了打字错误,你还能想到别的吗

<!DOCTYPE html>
<html>
<head>
    <title>Login</title>
</head>
<body>

<?php

if(!($sqlCon= mysql_connect("139.62.63...","cop..","abcdef")))
    die( "<p>Could not connect to database</p>" );

if (! ($dbCon = mysql_select_db("cop..", $sqlCon)))
    die( "<p>Could not open database</p>" );

// username and password sent from form
$myusername=$_POST['email'];
$mypassword=$_POST['password'];
$submit=$_POST['submit'];

        echo'<form name="Login" method="post">
                <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
                    <tr>
                    <td>
                        <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
                            <tr>
                                <td colspan="3"><strong>Member Login </strong></td>
                            </tr>
                            <tr>
                                <td width="78">Username</td>
                                <td width="6">:</td>
                                <td width="294"><input name="myusername" type="text" id="myusername"></td>
                            </tr>
                            <tr>
                                <td>Password</td>
                                <td>:</td>
                                <td><input name="mypassword" type="text" id="mypassword"></td>
                            </tr>
                            <tr>
                                <td>&nbsp;</td>
                                <td>&nbsp;</td>
                                <td><input type="submit" name="Submit" value="Login"></td>
                            </tr>
                        </table>
                    </td>
                </tr>
        </table>
                </form>';

if($submit) {
    // To protect MySQL injection (more detail about MySQL injection)
        $myusername = stripslashes($myusername);
        $mypassword = stripslashes($mypassword);
        $myusername = mysql_real_escape_string($myusername);
        $mypassword = mysql_real_escape_string($mypassword);

    $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
    $result=mysql_query($sql);

    // Mysql_num_row is counting table row
    $count=mysql_num_rows($result);

    // If result matched $myusername and $mypassword, table row must be 1 row
    if($count==1){

    // Register $myusername, $mypassword and redirect to file "login_success.php"
        session_register("myusername");
        session_register("mypassword");
        header("location:login_success.php");
    }
    else {
        echo "Wrong Username or Password";
    }
mysql_close($sqlCon);
}

    ?>

</body>
</html>

登录

连接到MySQL的密码不正确。检查您的配置。有趣的是,您正在创建一个登录表单来验证用户名密码,而实际上您的应用程序无法连接到数据库。

或ip,或用户名,或数据库未正确设置。否,我使用相同的密码连接到我的数据库,这很好:(@Dagon你说设置不正确是什么意思?在我的代码中还是在创建数据库时?#这个问题可能是服务器问题吗?所以无论是谁建立的都没有正确配置它???很高兴知道,谢谢:)哈哈,你是对的,但是我可以通过SSH连接到MySQL,没有问题。我怎么做?这不是我的服务器。这是学校为完成我的项目而提供的临时服务器。我可以访问这些日志吗?怎么做?这个问题可能是服务器问题吗?所以无论是谁建立的都没有正确配置它???你可以使用MySQL服务r?这就是你说的吗?这与mysql datatabase身份验证无关。