Jump to content

Why am I get access denied in my PHP script?


Recommended Posts

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>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...