MySQL/Apache Error in PHP MySQL query

Tags: mysql php
Question!

I am getting the following error:

Access denied for user 'apache'@'localhost' (using password: NO)

When using the following code:

<?php

include("../includes/connect.php");

$query = "SELECT * from story";

$result = mysql_query($query) or die(mysql_error());

echo "<h1>Delete Story</h1>";

if (mysql_num_rows($result) > 0) {
    while($row = mysql_fetch_row($result)){
          echo '<b>'.$row[1].'</b><span align="right"><a href="../process/delete_story.php?id='.$row[0].'">Delete</a></span>';
      echo '<br /><i>'.$row[2].'</i>';
    }
}
else {
   echo "No stories available.";
}
?>

The connect.php file contains my MySQL connect calls that are working fine with my INSERT queries in another portion of the software. If I comment out the $result = mysql_query line, then it goes through to the else statement. So, it is that line or the content in the if.

I have been searching the net for any solutions, and most seem to be related to too many MySQL connections or that the user I am logging into MySQL as does not have permission. I have checked both. I can still perform my other queries elsewhere in the software, and I have verified that the account has the correct permissions.



Answers

Just to check, if you use just this part you get an error?

If so, do you still get an error if you copy and paste one of those Inserts into this >page, I am trying to see if it's local to the page or that actual line.

Also, can you post a copy of the connection calls (minus passwords), unless the inserts >use exactly the same syntax as this example.

Here is what is in the connection.php file. I linked to the file through an include in the same fashion as where I execute the INSERT queries elsewhere in the code.

$conn = mysql_connect("localhost", ******, ******) or die("Could not connect");
mysql_select_db("adbay_com_-_cms") or die("Could not select database");

I will try the working INSERT query in this area to check that out.

As to the others posting about the password access. I did, as stated in my first posting, check permissions. I used phpMyAdmin to verify that the permissions for the user account I was using were correct. And if it matters at all, [email protected] is not the name of the user account that I use to get into the database. I don't have any user accounts with the name apache in them at all for that matter.

By : Mesidin


Just to check, if you use just this part you get an error?

<?php
include("../includes/connect.php");

$query = "SELECT * from story";
$result = mysql_query($query) or die(mysql_error());

If so, do you still get an error if you copy and paste one of those Inserts into this page, I am trying to see if it's local to the page or that actual line.

Also, can you post a copy of the connection calls (minus passwords), unless the inserts use exactly the same syntax as this example.

By : Teifion


This video can help you solving your question :)
By: admin