简体   繁体   中英

PHP/Mysql pagination: database connection issues

I am trying to set up pagination, but there is an annoying database connection error. Could you lend me a hand? Thanks!

<?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);

Here is the error message: Warning: mysql_query(): Access denied for user ''@'localhost' (using password: NO) in

If you use mysqli library for connection, please, use it for queries:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM