我已经尝试了我能想到的一切......从我的本地主机转到另一台服务器主机(由于我在他们的服务器上显然使用了ftp,它也使用了localhost),我仍然一直收到错误: 警告:mysqli :: mysqli()[mysqli.mysqli] :( 28000/1045):在/www/zxq.net/中拒绝用户'(审查)_zxq'@'192.168.1.1'(使用密码:YES)第6行的a / p / p /(审查)/htdocs/lib.php 连接失败:访问被拒绝用户'(审查)_zxq'@'192.168.1.1'(使用密码:是)
我已经尝试了多个支持mysql的主机...我一直收到错误,我知道我的凭据是正确的。我已经为数据库以及用户授予了权限。有什么建议? (ps。我向我审查了重要信息)
<?php
$server = 'localhost';
$login = '792981_kputts';
$password = 'whatup4u';
$database = '(censored)_zxq_ireport';
//access
$connection = new mysqli($server, $login, $password, $database);
//executes a given sql query with the params and returns an array as result
function query() {
global $link;
$debug = false;
//get the sql query
$args = func_get_args();
$sql = array_shift($args);
//secure the input
for ($i=0;$i<count($args);$i++) {
$args[$i] = urldecode($args[$i]);
$args[$i] = mysqli_real_escape_string($link, $args[$i]);
}
//build the final query
$sql = vsprintf($sql, $args);
if ($debug) print $sql;
//execute and fetch the results
$result = mysqli_query($link, $sql);
if (mysqli_errno($link)==0 && $result) {
$rows = array();
if ($result!==true)
while ($d = mysqli_fetch_assoc($result)) {
array_push($rows,$d);
}
//return json
return array('result'=>$rows);
} else {
//error
return array('error'=>'Database error');
}
}
//loads up the source image, resizes it and saves with -thumb in the file name
function thumb($srcFile, $sideInPx) {
$image = imagecreatefromjpeg($srcFile);
$width = imagesx($image);
$height = imagesy($image);
$thumb = imagecreatetruecolor($sideInPx, $sideInPx);
imagecopyresized($thumb,$image,0,0,0,0,$sideInPx,$sideInPx,$width,$height);
imagejpeg($thumb, str_replace(".jpg","-thumb.jpg",$srcFile), 85);
imagedestroy($thumb);
imagedestroy($image);
}
?>
答案 0 :(得分:0)
您的错误消息表明您没有从 localhost (127.0.0.1)进行连接,而是建立远程连接(* user'(已发送)_zxq'@'192.168.1.1'*)
进行远程连接时,请确保:
即使192.168.1.1是来自服务器的IP,它仍然被认为是远程连接,并且必须执行步骤2和3(有时也是1)。