Web Hosting Forum | Lunarpages
News: July 14, 2008 - New Contest! - Submit Your WordPress Theme Designs, Win BIG!
June 30, 2008 - Submit Your Site for the July 08 Site of the Month Award!
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
July 25, 2008, 05:09:28 PM


Login with username, password and session length


Pages: [1]   Go Down
  Print  
Author Topic: access denied for db connection  (Read 228 times)
blushifted
Spacescooter Operator
*****
Offline Offline

Posts: 30


« on: May 12, 2008, 12:29:11 AM »

Hi, I suck.  It's me your favorite noob (not boob unless you like man boobs, and even then I am not really into that sort of setup). I am trying to connect to the mysql database using php.  So heres the skinny.  I set up the connection based on another post that I found on the forum and I am getting an error.  here is the code if someone would like to have a go at it.:

<?php
$db = mysql_connect("localhost", "blushifted_xxxxxxx", "xxxxx");
mysql_select_db("blushifted_users", $db);
$query = "select * from example";
$result = mysql_query($query);
$table = mysql_field_table($result, 0);
echo $table;
?>

Anyway, if you have any thoughts that would be in good form (or bad) please do not hesitate to throwdown.  Lets get crackin'. Grr..!!
Logged
DragosF
SysAdmin
Trekkie
*****
Offline Offline

Posts: 18



« Reply #1 on: May 12, 2008, 01:51:01 AM »

Hello,

Could you please check that you have added the username (that is used on your script) with access to that database? This can be done from Cpanel, at MySQL® Databases.  You will have to scroll to locate the two drop down boxes with a button that says [Add User to Db]

    * In the drop down select box on the left, choose your newly created username, and in the box on the right, choose your newly created database.
    * Check "All" for Privileges.
    * Click Add User to Db.

This code will check if the MySQL connection is working:

Code:
<?php
$link 
mysql_connect('localhost''mysql_user''mysql_password');
if (!
$link) {
    die(
'Could not connect: ' mysql_error());
}
echo 
'Connected successfully';
mysql_close($link);
?>


For more details you can also check this: http://www.php.net/function.mysql-connect I hope this helps!
Logged
blushifted
Spacescooter Operator
*****
Offline Offline

Posts: 30


« Reply #2 on: May 12, 2008, 01:04:59 PM »

I was unable to follow your instructions.

I enter the control panel, select my domain, select databases under services, click on my new database, then it gives me the option to select the user?  Any thoughts from here on how to assign the permissions?  I dont have that option?  Maybe from the admin sight.
Logged
blushifted
Spacescooter Operator
*****
Offline Offline

Posts: 30


« Reply #3 on: May 12, 2008, 10:12:36 PM »

Ok, I was able to figure out.  I didnt need to pre-pend the account name to the database or the username.  Once I made this change I stopped getting errors.
Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM