Jump to content


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.


Connecting to a MySql DB

  • Please log in to reply
3 replies to this topic

#1 g2gsr93


  • Members
  • 21 posts
  • Local time:03:15 PM

Posted 20 August 2010 - 05:52 PM

I have a connect.php file that I include at the top of all pages that access my database with a require_once call. When I'm working on the site using my computer as the host everything works fine. But when I'm working on the actual webserver, it keeps saying

Warning: mysql_query() [function.mysql-query]: Access denied for user 'supplyso'@'localhost' (using password: NO) in /home2/supplyso/public_html/index.php on line 82

My connect.php file code looks like this
$connection = mysql_connect('localhost','supplyso_web','*********'); //connection variable for later use
if (!$connection)
	die('Could not connect to the database. ' . mysql_error()); //error for no connection
mysql_select_db('supplyso_main',$connection);//select db

You can see that the username I'm using is "supplyso_web" and the error above is saying 'supplyso@localhost. I'm not sure why this is happening. Thanks for any help you can provide!

Edited by g2gsr93, 20 August 2010 - 05:52 PM.

BC AdBot (Login to Remove)


#2 Romeo29


    Learning To Bleep

  • Members
  • 3,194 posts
  • Gender:Not Telling
  • Location:
  • Local time:02:15 PM

Posted 20 August 2010 - 07:46 PM

If you have enabled sql.safe_mode in your PHP configuration file (php.ini), then mysql_connect uses the default username and no password.

Edited by Romeo29, 20 August 2010 - 07:47 PM.

#3 g2gsr93

  • Topic Starter

  • Members
  • 21 posts
  • Local time:03:15 PM

Posted 20 August 2010 - 10:40 PM

Good idea but that wasn't it.

#4 groovicus


  • Security Colleague
  • 9,963 posts
  • Gender:Male
  • Location:Centerville, SD
  • Local time:01:15 PM

Posted 21 August 2010 - 04:47 PM

Have you granted access rights to that user on that database?

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users