473,320 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Access denied for user ''@'localhost' to database ??

hi guys

i have one error in php that coneect to the mysql database

the conecction is ok

but the selected the database is not work

the erorr is( Access denied for user ''@'localhost' to database )

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. $link = mysql_connect('localhost', '', '');
  4. if (!$link) {
  5.     die('Not connected : ' . mysql_error());
  6. }
  7.  
  8. // make aaa the current db
  9. $db_selected = mysql_select_db('amal', $link);
  10. if (!$db_selected) {
  11.     die ('Can\'t use amal : ' . mysql_error());
  12. }
  13. ?>
so plz anyone help me
Jan 15 '11 #1
6 9068
Dormilich
8,658 Expert Mod 8TB
I doubt that the connection is OK, since you get an Access Denied error, which is a typical connection error. you should pass an existing login name, an empty string is unlikely to work.
Jan 15 '11 #2
If you are trying to use the MySQL connection settings specified in the php.ini, you should omit the parameters to the mysql_connect altogether and let it fetch the defaults from php.ini

Otherwise like Dormilich said, you must specify the MySQL Username, and the matching Password.
Jan 16 '11 #3
Try to use this

mysql_connect("ip_address","username","password") or die("could not connected".mysql_error());

mysql_select_db("databasename") or die(mysql_error());
Jan 25 '11 #4
mfaisalwarraich
194 100+
try this:
Expand|Select|Wrap|Line Numbers
  1. $con = mysql_connect('hostname/ip-address', 'db_username','db_password') or die('could not connect to database'. mysql_error());
  2.  
  3. mysql_select_db('db_name', $con) or die('database not selected'. mysql_error());
  4.  
Jan 25 '11 #5
JKing
1,206 Expert 1GB
If you are developing locally using xampp or a similar product the default user is 'root' and the default password is ''.
Jan 26 '11 #6
mr5zz
2
@JKing

Yay! Thanks for mentioning the default user and password. I got it working now :)
May 6 '14 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Steve | last post by:
Hi, Yesterday I signed up for another dedicated linux server with the hosting company I use and I am having problems getting MySQL 4.1.3 working on it. I've tried just about everything I can...
3
by: Ian | last post by:
The beginning of my assembly that I am getting the access error from looks like this. ********************************* Imports System.EnterpriseServices Imports System Imports...
3
by: vincentw56 | last post by:
This is the first time I have tried this. What we have is a com object the generates keys. A developer here wrote a .Net wrapper in C# for this com object. I am trying to call her dll wrapper...
4
by: Fabian von Romberg | last post by:
Hi, I have installed Sql Reporting Services on 2 machines, one is WIN 2000 PRO and the other one is WIN 2000 ADV. SERVER. When I try to access a report using the webbrowser, I get the following...
12
by: Chad Crowder | last post by:
Hi all, I hope someone can give me a hand, because I'm out of ideas. I keep getting this message: Access to the path "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET...
6
by: ASP.Confused | last post by:
I have an ASP.NET page writtein in VB that uses ADODB. I just had to force-install MDAC 2.8 after I tried to rollback to 2.6 (my web host uses this, and I wanted to be compatible with them.) I...
0
by: ASP.Confused | last post by:
The old message looked a little stale, so I am re-posting it here. Anybody have any ideas of what I could do?!? The previous responses to this question are below. If you want to look at the...
1
by: karthi84 | last post by:
hi, when i tried to open a new excel spread sheet from my web form i got this access denied page. can any one help me in solving this problem. Server Error in '/sk/ContractInvoice'...
8
by: Jeremy Ames | last post by:
I am trying to move an application from my system to a new test system. I really should have tried an easier program first, but I didn't really have a chance. My application was originally written in...
1
by: zlf | last post by:
Hello my website has role based access, and user without specific role assigned cannot access specific page in website. When the user try to access a page who has not been granted to access, the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.