Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9029579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:16:46+00:00 2026-06-16T07:16:46+00:00

Sometimes I get this on my webserver log: [09-Dec-2012 15:35:45 Europe/Berlin] PHP Warning: mysql_query()

  • 0

Sometimes I get this on my webserver log:

[09-Dec-2012 15:35:45 Europe/Berlin] PHP Warning: mysql_query() [function.mysql-query]: Access denied
for user ‘root’@’localhost’ (using password: NO) in /bar/foo.php on
line 4

line 4 is:

$sql=mysql_query("select * from mytablefoo ORDER BY id DESC LIMIT 9");

It looks like somebody is trying to log in using a default root username.
Any way to prevent this, even if it’s not harmful?
How does he manage to connect through that line of code?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T07:16:47+00:00Added an answer on June 16, 2026 at 7:16 am

    Here is what I think is happening.

    You have one page (e.g.: index.php) that includes a second page (e.g.: /bar.foo.php). On the index.php, you make the primary connection:

    <?php
    //  index.php
    //  ...
    $db = mysql_connect($db, $username, $password);
    //  ...
    

    On the second page, you do some function:

    <?php
    //  /bar/foo.php
    //  ...
    mysql_query("select * from mytablefoo ORDER BY id DESC LIMIT 9"); // TODO: use mysqli or PDO here
    //  ...
    

    However, there is no database connection if you visit the second file directly, so it tries connecting with default credentials, fails, and throws an error.

    If you want to prevent this, then you need to secure your site. My guess is that people should never be allowed in your /bar folder. You can prevent people from entering this folder by adding an .htaccess file to this folder.

    .htaccess files let you control how users can interact with file on your site. Just create a new text file, and save it as .htaccess (this file doesn’t have anything before the .).

    Put this file inside of your /bar folder, and put the following text inside the file:

    deny from all
    

    Now, if anyone tries to visit this folder directly, they will be shown a 403 error message instead. The PHP files can still be included by other pages.

    You can learn more about .htaccess here:

    http://perishablepress.com/stupid-htaccess-tricks/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this error sometimes reported when creating a dialog, i haven't experienced the
i am making ajax calls with jquery like this http://pastie.org/860837 and sometimes i get
Sometimes users mistakenly redirected to ?Process=ViewImages&PAGEID=. When this happens, they get the following error.
Our mysql processes can sometimes get backlogged and processes begin queuing up. I'd like
Sometimes I get this error when extracting youtube videos by json, here's an example:
Sometimes I get this error, and I just want Rails to rescue/skip the error
The issue is that sometimes I get this error in Google Chrome when I
I try to deploy my app and sometimes get this error: Failure [INSTALL_FAILED_CONTAINER_ERROR] I
i have a problem with java swing. i sometimes get this NullPointerException at random
I sometimes get this exception. I dont really know where's problem, i use my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.