4

I am fairly new to web dev and I am in need of help trying to find out what the problem is. I had an install of MySQL 5.6.10 and I was given a task to update the src of a website that is currently live for past 5 years. None of the code has changed and it works for the other devs local machine. The server is running 5.0.51b and I just downgraded to 5.5.30 trying to get a syntax error to go away. The error was the SET OPTION SQL_BIG_SELECTS=1 was deprecated to SET SQL_BIG_SELECTS in a certain version. I am unable to change the syntax due to the version the server runs. So I chose to down version to 5.5.30.

My problem after the down grade is:

Warning: mysql_select_db() [function.mysql-select-db]: Access denied for user
''@'localhost' (using password: NO) in C:\Program Files (x86)\Apache Software
Foundation\Apache2.2\htdocs\****\src\www\include\func\func.db.php on line 47

I use MySQL Workbench for my connections none of the connections or users have passwords associated with them. I have another project that is not live that works fine from the localhost. My vhost and host files all have the proper syntax for this to work (verified with the other project). This all worked properly and was able to bring up the pages through vhost just fine yesterday. I never had any issues with how it was all setup to pull the index page. The only problem was the MySQL version issues. What can I do to fix this problem? I have tried recreating connections in the workbench and even deleting all the instances and recreating them. I am stumped. Any help would be greatly appreciated.

5
  • and with what credentials does the other project work? Commented Mar 20, 2013 at 18:13
  • Is your login script still accessible? Commented Mar 20, 2013 at 18:14
  • @Johan Are you talking about the error block for the warning? That is a single line error. Should I have broke this up? Also, I really dont think your comment is helpful. No need to be rude, imo. Commented Mar 20, 2013 at 18:30
  • If you're new to web dev, please avoid using mysql_query on new projects. This is a creaky, antiquated interface that's being removed from future versions of PHP. If you spend the small amount of time required to learn PDO, you'll have fewer problems with SQL escaping issues and won't have to re-write your application when mysql_query is no longer supported. If you're stuck working on a legacy application, be very careful. Commented Mar 20, 2013 at 18:32
  • 1
    @DanielVernon, reading blobs of text describing the problem all smashed into one paragraph is hard that's all. Commented Mar 20, 2013 at 18:33

4 Answers 4

4

You can see this error because you haven't connect your mysql database properly.

mysql_connect("HOST","USER","PASSWORD")

make sure the host, username and password is corrent

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

1 Comment

I am talking about your error. generally, this type of error come because you didn't configured your connection properly
2

Was MySQL the only thing you upgraded? Any chance you upgraded PHP and now no longer have register_globals on? If you have it off and your colleagues have it on, this could explain the differences you are seeing.

http://php.net/manual/en/security.globals.php

1 Comment

No I did not change my php version. I did have to update ereg_replace to preg_replace and add delimiters to the pattern.
1

Looking closely at your error you can see that it's telling you what is wrong (typically what error reports are for):

Access denied for user
''@'localhost' (using password: NO)

Looking specifically at:

''@'localhost'
^^

You see that no user was specified. You need to specify the user you wish to connect as.

mysql_connect("HOST","USER","PASSWORD")

Which comes before a mysql_select_db call.

MySQL Connect & MySQL Select DB

NOTICE: Don't upgrade to PHP 5.5 for MySQL_* functions have been deprecated. I say this since you do not wish to change any code.

2 Comments

Thank you. I noticed it was blank too and tried to find out where it is pulling the user from. I assume it is coming from y workbench. I have a connection for the db setup with a user that is the same as the user defined in my config.php for the site. Maybe I need to look into how the workbench is configured for the connections and work up from that. Any advice?
@DanielVernon I don't know much about the workbench but make sure the last mysql_connect is correct before you select a DB (preferably use mysql_connect or die()) and look into mysql_error. Your error said it occured at the select db. Also, if not specified, mysql_\* commands use the last opened connection if non specified
1

From what I am seeing in the error that has been returned, you did not pass the connection a username to use to connect to MySQL.

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.