mostafa581 Posted January 15, 2011 Share Posted January 15, 2011 Dear friends i,m a php beginner and i got a problem with connecting to my database i created a database called (koora) with one table called (admins) and when i tried to connect to it (database ) ; it did not connect here is the code i used for that <?php $connectdb = mysql_connect('localhost','','') or die("not connected"); $selectdb = mysql_select_db("koora", $connectdb); if(!$selectdb) { die("error connecting table" .mysql_error()); } then when refreshing my phpmyadmin page i got that message error connecting tableAccess denied for user ''@'localhost' to database 'koora' koora is the name of the database so i need your help with this problem and what is the reason not to connect to the data base Thank you Quote Link to comment https://forums.phpfreaks.com/topic/224477-problem-with-database-connection/ Share on other sites More sharing options...
marcus Posted January 15, 2011 Share Posted January 15, 2011 You need a username. Try using the username root. $connectdb = mysql_connect('localhost','root','') or die("fail"); $selectdb = mysql_select_db('koora',$connectdb); Quote Link to comment https://forums.phpfreaks.com/topic/224477-problem-with-database-connection/#findComment-1159604 Share on other sites More sharing options...
mostafa581 Posted January 15, 2011 Author Share Posted January 15, 2011 i tried it before but it gave me that message error connecting tableAccess denied for user ''@'localhost' to database 'koora' Quote Link to comment https://forums.phpfreaks.com/topic/224477-problem-with-database-connection/#findComment-1159623 Share on other sites More sharing options...
revraz Posted January 15, 2011 Share Posted January 15, 2011 Then maybe access is really denied. Did you confirm rights? Quote Link to comment https://forums.phpfreaks.com/topic/224477-problem-with-database-connection/#findComment-1159629 Share on other sites More sharing options...
mostafa581 Posted January 15, 2011 Author Share Posted January 15, 2011 Then maybe access is really denied. Did you confirm rights? what rights explain pls Quote Link to comment https://forums.phpfreaks.com/topic/224477-problem-with-database-connection/#findComment-1159794 Share on other sites More sharing options...
BlueSkyIS Posted January 15, 2011 Share Posted January 15, 2011 any user connecting to a MySQL database must have the proper login credentials to access the database. you must either set those login credentials (permissions) or find out what they are to use in this line: $connectdb = mysql_connect('localhost','USERNAME????','PASSWORD????') or die("not connected"); Quote Link to comment https://forums.phpfreaks.com/topic/224477-problem-with-database-connection/#findComment-1159809 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.