MySQL/Apache Error in PHP MySQL query

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.

I think I just need an outside perspective as I have been staring at this little block of code all day.

If any more information is needed, just let me know.

This question and answers originated from www.stackoverflow.com
Question by (8/5/2008 9:45:11 PM)

Answer

And if it matters at all, apache@localhost 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.

If it is saying 'apache@localhost' the username is not getting passed correctly to the MySQL connection. 'apache' is normally the user that runs the httpd process (at least on Redhat-based systems) and if no username is passed during the connection MySQL uses whomever is calling for the connection.

If you do the connection right in your script, not in a called file, do you get the same error?

Answer by

Find More Answers
Related Topics  php  mysql
Related Questions
  • mysql query error in php

    When I try execute query in mysql console - it's execute succesful, but in php it doesn't work. In php return error: Unknown column 'users.pwd' in 'field list' Query: SELECT users.`login`, …
  • PHP MySQL, Query error

    $sql = "UPDATE `$db_name`.`$tbl_name` SET `u_code` = '$u_code' WHERE `$tbl_name`.`email` = `$mail`;"; $result=mysql_query($sql); Whenever an email id (eg: mailme@gmail.com) is entered and t…
  • MySQL_Query error in PHP script

    The goal is that I would like to cycle through ALL of the .CSV files in my directory and run this script for each file so it appends the data into the DB. The issue stems from when I insert the loop…
  • mysql query error in php

    Select COUNT(*) as num t1.id,t1.ads_city,t1.ads_title,t1.ads_description,t1.ads_location,t2.ads_date,t2.ads_image,t2.ads_id,t2.ads_time,t2.postads_id ,t2.ads_url FROM postads t1 JOIN nextpostads…
  • Occasional MySQL query Error in PHP

    I have a php file that has to be loaded as a web page. This page is 17Kb in size. It has a php mysql query script inside. the problem now, sometimes my mysql_query() lines gives an error. When be…
  • mysql_num_rows error in PHP with mysql_query

    Hi i am too new too php and mysql and i want to count the member number due to the search made by user. However, mysql_num_rows doesnt work. mysql_num_rows(mysql_query("SELECT * FROM members WHER…
  • Getting Error in PHP MySQL "Insert" query

    I'm getting the following error while executing the qurey, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''…
  • PHP mysql_query error

    I'm trying to learn and I'm stuck. I don't understand why this doesn't work. If I just leave the include and remove the function call and don't wrap the database connection in a function it works pr…
  • MySQL/PHP update query error

    I'm running a query to update a small group of 'items' in a table, from PHP. Running the code with "Sequel Pro" executes it perfectly, while running it on PHP using mysql("query here"); fails misera…
  • Error in MySql query

    I have three tables. I am attempting to pull data from two tables and insert into the third if a set of circumstances exists. When I run my query I am getting "#1054 - Unknown column 'rvp_to_r…