access denied in mysql

Status
Not open for further replies.

diaga09

New Member
Messages
3
Reaction score
0
Points
0
hello im having problems connecting to mysql...when im using my own server its working perfectly fine so it mean i dont have any problem with my php scripts...i ftp all my files and change the connection to localhost,myusername,mypassword,mydatabase im getting error saying Warning: mysqli::connect() [mysqli.connect]: (28000/1045): Access denied for user 'diaga09_omeng'@'localhost' (using password: YES) in /home/diaga09/public_html/classes/adminlogin.php on line 21
Couldnt connect to database.. i followed the format using ("localhost","cpanelusername_mysqlusername","mysql_password","mysqlusername_database");...thanks in advance...
 

Gouri

Community Paragon
Community Support
Messages
4,565
Reaction score
245
Points
63
hello im having problems connecting to mysql...when im using my own server its working perfectly fine so it mean i dont have any problem with my php scripts...i ftp all my files and change the connection to localhost,myusername,mypassword,mydatabase im getting error saying Warning: mysqli::connect() [mysqli.connect]: (28000/1045): Access denied for user 'diaga09_omeng'@'localhost' (using password: YES) in /home/diaga09/public_html/classes/adminlogin.php on line 21
Couldnt connect to database.. i followed the format using ("localhost","cpanelusername_mysqlusername","mysql_password","mysqlusername_database");...thanks in advance...

Hi diaga09,

It is not
("localhost","cpanelusername_mysqlusername","mysql_password","mysqlusername_database");


It should be
("localhost","cpanelusername_mysqlusername","mysql_password","cpanelusername_database");

Check out once.
 

diaga09

New Member
Messages
3
Reaction score
0
Points
0
many thanks

thanks mate...you've solved my problem...im just a newbie in php...one more thing...can you check my codes coz now im having errors saying:

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in /home/diaga09/public_html/classes/adminlogin.php on line 30

thanks in advance mate...
<?php
include("adminuser.php");
class AdminLogin extends AdminUser{
private $success;
//create constructors
public function __construct($user,$pass){
$this->username=$user;
$this->password=$pass;
$this->login();
}//end of construct
public function Login(){
//create connection to database

$con = new mysqli();
$con->connect("localhost","my_user","Mypassword","database");
//check if there's no error in connecting to database
if (mysqli_connect_error()){
die ("Couldnt connect to database");
}
//start the query
$result=$con->query("select * from admin where username='{$this->username}' AND password='{$this->password}'");
if (mysqli_num_rows($result)>0){
$this->success=true;
}else{
$this->success=false;
}
//close the connection
$con->close();
return $result;

}//end of login function
public function LoginSuccess($value=""){
if ($value==""){
return $this->success;
}else{
$this->success=$value;
}
}//end of login success




}//end of adminlogin

?>
 

vishal

-::-X10 Guru-::-
Community Support
Messages
5,255
Reaction score
192
Points
63
Because the number of rows returned only makes sense with a particular result set. However, for a SELECT query mysqli_query() can return a result resource (representing a result set) or false (a boolean).
Here its not fetching anything,is the connection ok
 

diaga09

New Member
Messages
3
Reaction score
0
Points
0
fixed it

thanks guys...fixed it...one of my table doesnt match from my script....many thanks...
 

vishal

-::-X10 Guru-::-
Community Support
Messages
5,255
Reaction score
192
Points
63
Re: fixed it

thanks guys...fixed it...one of my table doesnt match from my script....many thanks...
So u fixed it ... PM if u have any doubts
Enjoy mate
 
Status
Not open for further replies.
Top