0

This is the code I am having trouble with:

<?php

mysql_connect('localhost', 'username', 'password') or die(mysql_error());
mysql_select_db('database') or die(mysql_error());

$posts = mysql_query("SELECT * FROM  `wp_DevBlogposts` ORDER BY  `wp_DevBlogposts`.`post_date` DESC LIMIT 2") or die(mysql_error());

while($row = mysql_fetch_array($posts)){

$post_name = $row['post_title']; // Post Name/Title
$post_content = $row['post_content']; // Post Content
$url = $row['guid']; // Post URL

}
?>
<!DOCTYPE html>

<html>

<body>

    <table>
        <tr>
            <td>
            <b><a href='$url'><?php echo $post_name; ?></a></b>
            </td>
            <td>
            <b><?php echo $post_content; ?></b>
            </td>
        </tr>
    </table>
    <br />
</body>

</html>

This code is completely valid, it is constantly spitting up this error:

Access denied for user 'username'@'localhost' to database 'database_database'

The problem is that I can connect to all of the other tables but this one keeps giving me that error. I don't know why I would be able to connect to all the other tables but this one. Thanks for helping!

2
Contributors
4
Replies
6
Views
4 Years
Discussion Span
Last Post by LastMitch
3

@Djmann1013

The problem is that I can connect to all of the other tables but this one keeps giving me that error. I don't know why I would be able to connect to all the other tables but this one.

It means that username has not been grant access to that db. Did you give this username perrmission to access the db? If not then you should gave that username access.

Edited by LastMitch: grammer

Votes + Comments
To Rectify what some retard did to LastMitch
Thanks!
0

I am using a webhost called x10Hosting. I am not sure if I can grant access to the username. If I can, then what do I do?

Thanks

0

@Djmann1013

I am using a webhost called x10Hosting. I am not sure if I can grant access to the username. If I can, then what do I do?

You figure it out?

You know there alot of host server like bluehost or godaddy or xhosting. It's really hard to give you a straight answer about:

Access denied for user 'username'@'localhost' to database 'database_database'

I only gave you a outline of the issue. In order to fixed that issue is to let the username access.

But I'm glad you solve it!

Edited by LastMitch: grammer

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.