0

I created a forum on my site using my my website provider, it created the database for me and uploaded the forum, etc. Previously I uploaded the forum and created the db myself but for some reason the releases of phpbb3 are riddled with stuff like missing ?> tags

I'm trying to connect to the db using my own script, I have a few other databases which I created, and they work fine, except this one which was made by my provider

$con = mysql_connect('ip','user','pass');
if (!$con) {
    die('Not connected : ' . mysql_error());
}

$db_selected = mysql_select_db('forum',$con);
if (!$db_selected) {
    die ('Can\'t use db : ' . mysql_error());
}

I get Can't use db : Access denied for user 'user'@'%' to database 'forum'

EDIT: (fixed) was missing variable named $db_selected

3
  • Are you running this script on the same server the forum runs on? Commented Jul 21, 2013 at 2:28
  • @Andy yes. im trying to connect to the database, and show news articles on my website (index) from under phpbb3_posts Commented Jul 21, 2013 at 15:27
  • I also switched databases for forums (i created it this time) to see if it would change(uploaded all previous data), still get same error Commented Jul 21, 2013 at 15:27

1 Answer 1

1

Assuming that the user you want to use to access the database is called "user", check the following

1) Switch current db to mysql, and check if the user exists (there is a row having Host = % in the results of the following query)

USE mysql;
SELECT * FROM user WHERE user = 'user'

2) Check if this user has permissions for the database (there is a row having Db = database and host = %)

SELECT * FROM db WHERE user = 'user'

3) If this looks fine, try to flush privileges by the following:

FLUSH PRIVILEGES;

Then try to log in .. it may help.

The full step by step how to create a user and grant privileges is here:

http://dev.mysql.com/doc/refman/5.1/en/adding-users.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.