I have tried everything I can think of...going from my localhost to another servers host (which also uses localhost since I am using ftp on their servers apparently), and I still keep getting the error: Warning: mysqli::mysqli() [mysqli.mysqli]: (28000/1045): Access denied for user '(censored)_zxq'@'192.168.1.1' (using password: YES) in /www/zxq.net/a/p/p/(censored)/htdocs/lib.php on line 6 Connect failed: Access denied for user '(censored)_zxq'@'192.168.1.1' (using password: YES)
I have tried multiple hosts with mysql support too...I keep getting that error and I know that my credentials are right. AND I have given permissions to the database as well to the user. Any suggestions? (ps. I censored the important information to me)
<?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);
}
?>
Your error message suggest that you are not connecting from localhost (127.0.0.1) but making a remote connection( *user '(censored)_zxq'@'192.168.1.1'* )
When making a remote connection make sure that:
Even if 192.168.1.1 is the IP from the server, it is still considered a remote connection, and steps 2 and 3 (sometimes also 1) have to be performed.