-1

同じエラー メッセージが表示され続ける (警告: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/) 00/7882800/html/Connections/dueslogin.php 27 行目 データベースに接続できません!後でもう一度お試しください。)

 <?php
        //Variables for connecting to your database.
        //These variable values come from your hosting account.
        $hostname = "TarHeelsDues.db.7882800.hostedresource.com";
        $username = "TarHeelsDues";
        $dbname = "TarHeelsDues";

        //These variable values need to be changed by you before deploying
        $password = "************";
        $usertable = "DuesLogin";
        $yourfield = "your_field";

        //Connecting to your database
        mysql_connect($hostname, $dbname, $password) OR DIE ("Unable to 
        connect to database! Please try again later.");
        mysql_select_db($TarHeelsDues);

        //Fetching from your database table.
        $query = "SELECT * FROM $usertable";
        $result = mysql_query($query);

        if ($result) {
            while($row = mysql_fetch_array($result)) {
                $name = $row["$yourfield"];
                echo "Name: $name<br>";
            }
        }
        ?>
4

3 に答える 3

3

mysql_connect 行を次のように変更します

mysql_connect($hostname, $username, $password) OR DIE ("Unable to 
    connect to database! Please try again later.");

mysql_select_db($dbname);
于 2012-10-26T05:59:19.517 に答える
1

The correct syntax should be like this:-

mysql_connect($hostname, $username , $password) OR die ("Unable to connect with the server"); mysql_select_db($TarHeelsDues) or die('Cannot connect with the database!');

于 2012-11-04T11:07:14.900 に答える
1

mysql_connect で $dbname ではなく $username を使用する必要があります。

 mysql_connect($hostname, $username , $password) OR DIE ("Unable to 
        connect to database! Please try again later.");
        mysql_select_db($TarHeelsDues);
于 2012-10-26T06:36:29.533 に答える