bri4n Posted February 25, 2007 Share Posted February 25, 2007 Hi everybody! I am learning how to write a login page in PHP and when I go to login witht a mock username and password (which is stored in a MySQL db) I get the following: Warning: mysql_connect(): Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Inetpub\vhosts\god-zone.org.nz\httpdocs\Login.php on line 13 Couldn't connect to server. The db connection information is in an include file which is called by the Login.php page. Here is the include file: <?php $user="members"; $host="localhost"; $password=""; ?> and here is the Login.php portion: session_start(); include("dogs.inc"); switch (@$_GET['do']) { case "login": $connection = mysql_connect($host,$username,$password) or die ("Couldn't connect to server."); $db = mysql_select_db($database, $connection) or die("Couldn't select database"); As far as I can tell haven't done anything wrong, but I just can't figure out why it doesn't work! Grrrrrrrrrrrrr I really appreciate any help in helping resolve this simple problem! Thanx, Brian :-) Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 25, 2007 Share Posted February 25, 2007 When I created mine I had a smimilar prob. Where you have localhost I had to put mysql. Don't know about yours though. It is odd that you don't need a pass though. Quote Link to comment Share on other sites More sharing options...
bri4n Posted February 25, 2007 Author Share Posted February 25, 2007 Hey Greaser! I changed $host form "localhost" to "mysql" but still no joy... :'( Thanx, Brian :-) Quote Link to comment Share on other sites More sharing options...
magic2goodil Posted February 25, 2007 Share Posted February 25, 2007 You probably do need a password there and if you're doing that on your local machine, your $username should be root. Quote Link to comment Share on other sites More sharing options...
Archadian Posted February 25, 2007 Share Posted February 25, 2007 Warning: mysql_connect(): Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\Inetpub\vhosts\god-zone.org.nz\httpdocs\Login.php on line 13 Couldn't connect to server. It doesn't have anything to do with changing localhost to mysql...leave localhost as it is. You need to go into your database using the root username (with phpMyAdmin, etc.) and create a user, in this case ODBC and give it full rights to everything, then make a password for it. Its giving you that error because as of now, ODBC has no rights to even connect to the database. Quote Link to comment Share on other sites More sharing options...
bri4n Posted February 25, 2007 Author Share Posted February 25, 2007 Hi Archadian! That got it! I created a new user:ODBC and now it's functioning . There was a user created previously by me: members. I was wondering if you could tell me how I could replace the user:ODBC with the user: members. Thanx, Brian :-) Quote Link to comment Share on other sites More sharing options...
btherl Posted February 25, 2007 Share Posted February 25, 2007 Hi Brian, I'm Brian Sometimes it's the easiest things that are the hardest to spot.. In your include file, you set $user, but in Login.php you use $username. That results in an empty username being passed, which somewhere gets changed to a default "ODBC" username. Quote Link to comment Share on other sites More sharing options...
bri4n Posted February 25, 2007 Author Share Posted February 25, 2007 Hi Brian! Thanks for your reply, it was very helpful!! Thanx Brian Quote Link to comment Share on other sites More sharing options...
rameshfaj Posted February 25, 2007 Share Posted February 25, 2007 You have certainly problem with the username and/or password.Either these values are incorrect or these values (sometimes password)not required.By default the user name is set to root. Simply connect to the mysql server as: mysql -u root: Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.