警告:mysqli_connect():( 28000/1045):拒绝访问

时间:2016-05-29 13:19:40

标签: mysql database

我的网页上有两个错误。而且我不习惯使用数据库,mysql,所以我需要你来帮助我!

  

警告:mysqli_connect():( 28000/1045):拒绝用户访问' u467224226_yjygu' @' 10.1.2.19' (使用密码:是)在第8行的/home/u467224226/public_html/galeria/api.php

     

警告:mysqli_error()要求参数1为mysqli,第8行/home/u467224226/public_html/galeria/api.php中给出布尔值

这是代码。

<?php // connect to the database $user_name = ""; $password = ""; $database = ""; $host_name = "localhost";

$con = mysqli_connect($host_name ,$user_name ,$password,$database) or die("Error " .       mysqli_error($con)); //check connection

echo "Connection opened";

mysql_close($con); ?>

<?php   require_once('include/config.inc.php');     header("Content-type: application/x-javascript");


            $connect = mysql_connect($CONFIG['dbserver'],$CONFIG['dbuser'],$CONFIG['dbpass'])       or die('Erro ao conectar ao servidor');     $connect_db = mysql_select_db($CONFIG['dbname'], $connect)      or die ('Erro ao conectar ao banco de dados');


                $resultado = mysql_query("SELECT * FROM `cpg_albums` ORDER BY `cpg_albums`.`aid` DESC LIMIT 0 , 4", $connect)

                    or die('Nenhum album encontrado com esta query');

                    echo 'document.write(\'';

                    if(mysql_num_rows($resultado) == 0){
                        echo 'Nenhum álbum cadastrado';
                    } else { echo '<section id="ultimas_fotos">  ';
                        while($row = mysql_fetch_array($resultado)){
                            echo ' ';
                                $album_id = $row['aid'];
                                $subresult = mysql_query("SELECT * FROM `cpg_pictures` where aid=$album_id order by pid DESC LIMIT 0, 20");

                                if(mysql_num_rows($subresult) == 0){
                                    $album_img = "http://tisdalephotos.com/images/thumbs/thumb_nopic.png";
                                } else {
                                    while($subrow = mysql_fetch_array($subresult)){
                                        $album_img = "http://tisdalephotos.com/albums/".$subrow['filepath'].'thumb_'.$subrow['filename'] .$subrow['datebrowse'];

                                    }
                                }

                                echo '<div id="ultalb"><a href="http://tisdalephotos.com/thumbnails.php?album='.$album_id.' "><img src="'.$album_img.'" alt="" /></a><div id="ultalbt"><a href="http://tisdalephotos.com/thumbnails.php?album='.$album_id.' ">+</a></div></div>';   

                            echo '';
                        }
                    }

echo '</tr></section>';
                    echo '\');';
                            ?>

1 个答案:

答案 0 :(得分:0)

假设您输入的密码正确无误。

您的用户是否拥有正确的权限?以root身份登录然后运行:

select Host, User from mysql.user;

查看为您的用户列出的内容。

如果它丢失了,你可以运行:

CREATE USER 'u467224226_yjygu'@'%%' IDENTIFIED BY 'PASSWORD';
GRANT ALL PRIVILEGES ON * . * TO 'u467224226_yjygu'@'%%';
FLUSH PRIVILEGES;