njaohnt Posted August 12, 2011 Posted August 12, 2011 I have a PHP script that comes out with this response: Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'njaohnt_jzaucts'@'localhost' (using password: YES) in /home1/njaohnt/public_html/status.php on line 2 Could not connect: Access denied for user 'njaohnt_jzaucts'@'localhost' (using password: YES) Here's my code, and I'll change the password later. <html><body><?php $con = mysql_connect("localhost","njaohnt_jzaucts","passwordhere"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("njaohnt_jzdbauctions", $con); $result = mysql_query("SELECT * FROM Persons"); echo "<table border='1'> <tr>"; for ($i2=0; $i2<16; $i2++) {echo "<th>" . $bidrow[$i2] . "</th>";} echo "</tr>"; $bidrow=array("Title","Timed","Timeh","Timem","Times","Owner","bidtyal","Prdes","cat","typs","chats","bidhi","Peobidg","curam","topbidr"); while($row = mysql_fetch_array($result)) { for ($i=0; $i<16; $i++) { echo "<tr>"; echo "<td>" . $bidrow[$i] . "</td>"; echo "</tr>"; } } echo "</table>"; mysql_close($con); ?> </body></html>
Guest Geoff Posted August 12, 2011 Posted August 12, 2011 Try logging in with your cpanel username and password (don't post it here!).
PenTester Posted August 12, 2011 Posted August 12, 2011 Are you sure about database and passwords? Once again check it
njaohnt Posted August 13, 2011 Author Posted August 13, 2011 I used the password for my cPanel, and it worked! Thank you.
Krydos Posted August 13, 2011 Posted August 13, 2011 I used the password for my cPanel, and it worked! Thank you. That means that you didn't have your user or permissions set up correctly for the database you were trying to use. Your cpanel login and password is basically root for your database and has all permissions.
njaohnt Posted August 14, 2011 Author Posted August 14, 2011 I did though. I set all permissions to that user.
PenTester Posted August 16, 2011 Posted August 16, 2011 Your data is right and you have set all permission but still have problem? I am not able to realize what is your problem. But suppose if i got this problem, i'll create a simple php file to test the connection.
njaohnt Posted August 27, 2011 Author Posted August 27, 2011 I don't know what happened, but now it works with my original code.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now