我用的集成环境,在运行的时候报本地服务器受限的错误提示,如下:
Warning: mysql_pconnect() [function.mysql-pconnect]: Access denied for user 'root'@'localhost' (using password: YES) in D:\AppServ\www\wg.shop\class\db_Conn.php on line 22Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user 'ODBC'@'localhost' (using password: NO) in D:\AppServ\www\wg.shop\class\db_Conn.php on line 24Warning: mysql_select_db() [function.mysql-select-db]: A link to the server could not be established in D:\AppServ\www\wg.shop\class\db_Conn.php on line 24Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in D:\AppServ\www\wg.shop\class\db_Conn.php on line 69Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in D:\AppServ\www\wg.shop\class\db_Conn.php on line 69Warning: mysql_affected_rows() [function.mysql-affected-rows]: A link to the server could not be established in D:\AppServ\www\wg.shop\class\db_Conn.php on line 71
请问是怎么回事了?

解决方案 »

  1.   

    <?php
    // Connecting, selecting database
    $link = mysql_connect('mysql_host', 'mysql_user', 'mysql_password')
        or die('Could not connect: ' . mysql_error());
    echo 'Connected successfully';
    mysql_select_db('my_database') or die('Could not select database');// Performing SQL query
    $query = 'SELECT * FROM my_table';
    $result = mysql_query($query) or die('Query failed: ' . mysql_error());// Printing results in HTML
    echo "<table>\n";
    while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
        echo "\t<tr>\n";
        foreach ($line as $col_value) {
            echo "\t\t<td>$col_value</td>\n";
        }
        echo "\t</tr>\n";
    }
    echo "</table>\n";// Free resultset
    mysql_free_result($result);// Closing connection
    mysql_close($link);
    ?>