PHP / Mysql分页:数据库连接问题

时间:2013-10-15 11:08:00

标签: php mysql pagination database-connection

我正在尝试设置分页,但是存在恼人的数据库连接错误。你能借给我一个手吗?谢谢!

<?php
        include('includes/db_AF.php'); //includes the db credentials
        $connection = @new mysqli(HOSTNAME, MYSQLUSER, MYSQLPASS, MYSQLDB);
        if ($connection->connect_error) {
        die('Connect Error: ' . $connection->connect_error);
        }
        else {

if (!(isset($pagenum))) 
{ 
$pagenum = 1; 
} 


 $data = "SELECT * FROM wordtable2"; 
$data1 = mysql_query($data);
 $rows = mysql_num_rows($data1);

以下是错误消息: 警告:mysql_query():用户''@ localhost'拒绝访问(使用密码:NO)

1 个答案:

答案 0 :(得分:0)

如果您使用mysqli库进行连接,请将其用于查询:

$result = mysqli_query($connection_obj, $query); 
$count = mysqli_num_rows($result)