Jump to content


Photo

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


  • Please log in to reply
5 replies to this topic

#1 drunkpanda

drunkpanda

    Newbie

  • New Members
  • Pip
  • 3 posts

Posted 07 April 2006 - 12:46 PM

I got error message like this:

1. [!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]Access denied for user 'ODBC'@'localhost' (using password: NO) [!--colorc--][/span][!--/colorc--]
2. Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in
C:\xampp\xampp\htdocs\xampp\PHPFreaks\login.php on line 21



include $_SERVER['DOCUMENT_ROOT'].'/XAMPP/PHPFreaks/layout.php';

switch($_REQUEST['req']){
    case "validate":
        
        $username = $_POST['username'];
        $password = $_POST['password'];
        
        print $username." ". $password."<br />";
        
        $validate = @mysql_query("SELECT * FROM members
                                  WHERE username = '$username')
                                  AND password = md5('$password')
                                  AND verified = '1' ");
                                  
         echo mysql_error()."<br />";                      
         echo $validate."don't tell me there is nothing";
        
         
        if(mysql_num_rows($validate) == 1){         <------------- Line 21
                 ....................... more
XAMPP for Windows
-MySQL 5.0.18
-Apache 2.2.0
-PHP 5.1.1
-phpMyAdmin 2.7.0 pl1

I have tired to google the error but I couldn't find the solution
can somebody help me with it
thank you
drunkpanda



#2 wildteen88

wildteen88

    Advanced Member

  • Staff Alumni
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 07 April 2006 - 01:48 PM

How are you connecting to your MySQL database? As this the reaosn why you're getting this error:

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

And yu are getting the secound error because your SQL syntax is wrong. This is what it should be:
$validate = mysql_query("SELECT * FROM members WHERE username = '$username' AND password = md5('$password') AND verified = '1'");


#3 drunkpanda

drunkpanda

    Newbie

  • New Members
  • Pip
  • 3 posts

Posted 08 April 2006 - 01:46 AM

first I want to thank you

[!--quoteo(post=362614:date=Apr 7 2006, 01:48 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 7 2006, 01:48 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
How are you connecting to your MySQL database? As this the reaosn why you're getting this error:

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

And yu are getting the secound error because your SQL syntax is wrong. This is what it should be:
$validate = mysql_query("SELECT * FROM members WHERE username = '$username' AND password = md5('$password') AND verified = '1'");
[/quote]

how I connect to my MySQL database?
<?php
//connect to mysql
$sql = mysql_connect('localhost','root');

//select database: PHPFreaks
mysql_select_db('PHPFreaks',$sql) or die(mysql_error());
?>
I didn't setup password, because I doing it on my computer as practice so
I don't think thats necessary


About my SQL error. The sounds interesting. because I got the syntax from a book call
"Creating Interactive Websites with PHP Web Services" and the author is Eric Rosebrock
which I think is the owner of this website.

thank you
Drunkpanda


#4 wildteen88

wildteen88

    Advanced Member

  • Staff Alumni
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 08 April 2006 - 07:14 AM

Im not sure why your're getting the error you're recieving. Could you change your MySQL conntect code to this:
$sql = mysql_connect('localhost','root') or die("Cannot Connect to MySQL: " . mysql_error());
Did you get a different error message this time? If so could you post the full message here.

#5 drunkpanda

drunkpanda

    Newbie

  • New Members
  • Pip
  • 3 posts

Posted 09 April 2006 - 09:56 AM

[!--quoteo(post=362786:date=Apr 8 2006, 07:14 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Apr 8 2006, 07:14 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Im not sure why your're getting the error you're recieving. Could you change your MySQL conntect code to this:
$sql = mysql_connect('localhost','root') or die("Cannot Connect to MySQL: " . mysql_error());
Did you get a different error message this time? If so could you post the full message here.
[/quote]

I change everything just like you said but

Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\wamp\www\PHPFreaks\login.php on line 16

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\wamp\www\PHPFreaks\login.php on line 16
Access denied for user 'ODBC'@'localhost' (using password: NO)

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\PHPFreaks\login.php on line 21

thank you
drunkpanda

#6 txmedic03

txmedic03

    Advanced Member

  • Members
  • PipPipPip
  • 313 posts
  • LocationCall, TX, USA

Posted 11 April 2006 - 09:16 PM

Check the password for that user, if that user even exists, and make sure that the user indeed exists and has the proper permissions to do what you are attempting.

The (using password: NO), of course, means that you did not pass any password to the server. The username of the user is 'ODBC'. Try using 'root' and see what happens. If you use phpMyAdmin and you can successfully login from there you can check the user from the mysql table and see if ODBC exists and see if it has a password or not.

as for your SQL syntax...yes, Eric, owns this site, as far as I know, but I see only two things at a glance and one just looks like a typo. The first thing is the ')' after '$username'. Secondly, integers such as 1 do not require any kind of quotes. That's not to say that quotes around an integer is going to bring about the destruction of the Earth, but it is bad practice to tell the interpreter that your integers are strings. If you were to write a funtion that specifically required an integer and you passed a string it could cause you some headaches.

SEMPER FIDELIS!

I can't stop you from doing something silly, but at least I can help you do it right.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com