Click here to Skip to main content
15,892,768 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone

I tried to access to database from php but i couldn't after some attempts
this is the code

PHP
$mysqli = new mysqli("ipAddress(hostname)", "UserName", "Password", "DbName");

   if($mysqli->connect_error) 
     die('Connect Error (' . mysqli_connect_errno() . ') '. mysqli_connect_error());

   else echo "Success";


also this

PHP
$dbhandle = mysql_connect("ipAddress(hostname)", "UserName", "Password") 
		
		 or die("Unable to connect to MySQL");
		 
		//echo "Connected to MySQL<br>";

		//select a database to work with
		$selected = mysql_select_db("DbName",$dbhandle) 
		  or die("Could not select Database");


give me error messsage

Access denied for user 'UserName'@'ipAddress' (using password: YES) in ../client.php



but when I use C#
No Error Message

C#
string query = string.Format("Select {0} from information_schema.tables ", "table_name");
            MySqlDataAdapter DA = new MySqlDataAdapter(query,"Server=ipAddress;User Id=userName;Password=Password;Database=DbName");

            DataSet Ds = new DataSet();
            DA.Fill(Ds, "Tables");



plz help me

What I have tried:

I tried to use many different codes in php but i couldn't to access database
Posted
Updated 18-Mar-17 7:36am
v4
Comments
Bryian Tan 18-Mar-17 13:47pm    
Are you using MySQL Workbench?
Ammar Al-hamdabni 18-Mar-17 14:02pm    
No, I'm not.
Bryian Tan 18-Mar-17 14:06pm    
hmmm, In Workbench, under user privileges, user accounts, I can setup the account to allow from any host (%). Maybe there something similar in whatever tools that you use to manage the MySQL server?
Ammar Al-hamdabni 18-Mar-17 14:13pm    
no problem thanx

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900