nikto Posted April 10, 2007 Share Posted April 10, 2007 i am getting this msg on the site : warning: mysql_connect() [function.mysql-connect]: Access denied for user 'stelios_mychat1'@'localhost' (using password: YES) in /home/stelios/public_html/Pages/home.php on line 103 I cannot connect to the database because: Access denied for user 'stelios_mychat1'@'localhost' (using password: YES) the line (103) : <?php $dbh=mysql_connect ("localhost", "stelios_mychat1", "123456789") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("stelios_stelios"); $sql = "SELECT id,username FROM TABLE"; $result = mysql_query($sql); //$link = \"<a href=\'profile.php?id=$row[id]\'>\"; //uncomment $link and $el if you want it linkable $td = "<td>"; //$el = \"</a>\"; echo "<table border=0 cellspacing=0 cellpadding=2 width=200>"; echo "<tr><td>ID<td>Username"; while ($row = mysql_fetch_array($result, MYSQL_BOTH)) { echo "<tr><td>"; printf ("%s $td $link %s $el", $row[0], $row["username"]); } mysql_free_result($result); ?> can any1 please help me? :-) EDITED BY WILDTEEN88: PLease use code tags ( )when posting code. Also please try to write your posts in full english and not in shortened english/txt speak. Also try to make your threads title as descriptive as possible. I have modified your threads title to be more descriptive. Quote Link to comment https://forums.phpfreaks.com/topic/46470-mysql-error-access-denied/ Share on other sites More sharing options...
MadTechie Posted April 10, 2007 Share Posted April 10, 2007 Double check the username & password Quote Link to comment https://forums.phpfreaks.com/topic/46470-mysql-error-access-denied/#findComment-226067 Share on other sites More sharing options...
nikto Posted April 17, 2007 Author Share Posted April 17, 2007 Can someone explain to me how i ll see the username and password in cpanel please.I would prefer explaing to me in steps...thank you. Quote Link to comment https://forums.phpfreaks.com/topic/46470-mysql-error-access-denied/#findComment-231381 Share on other sites More sharing options...
MadTechie Posted April 17, 2007 Share Posted April 17, 2007 to setup a database in cPanel follow these steps 1. Load up cPanel 2. goto MySQL® Databases 3. Create a Database 3.1 find "New Database: " (in the 'Current Databases' section) and type the database name and click Create database for this example i am going to use "MyDatabase" the Next screen should say MySQL Account Maintenance Database Created Added the database MyDatabase. SIDE NOTE: on my account the database is prefixed with the domain name ie MyDome_MyDatabase Keep note of this 3.2 Click Go Back 4. Now Create the user account 4.1 goto the 'Current Users' section 4.2 Enter a username and password (for this example i am going to use User:User and Password: Pass) 4.3 click Create User you should see the following screen MySQL Account Maintenance Account Created Added user with the password password SIDE NOTE: on my account the username is prefixed with the domain name ie MyDome_user, the password isn't, Keep note of this 4.4 Click Go Back 5.0 setup access 5.1 goto Add Users To Your Databases section 5.2 change user to 'user' (in my case MyDome_user) 5.3 change database to 'MyDatabase' (in my case MyDome_MyDatabase) 5.4 under Privileges: select ALL (you can change this later but for testing use all) 5.5 Click Add User to Database you should see a screen like this MySQL Account Maintenance Account added to Access List Added the user MyDome_user to the database MyDome_MyDatabase. So User:MyDome_user pass:password database:MyDome_MyDatabase host:local i hope that helps Quote Link to comment https://forums.phpfreaks.com/topic/46470-mysql-error-access-denied/#findComment-231508 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.