Jump to content

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


Recommended Posts

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 [b]21[/b]


[code]

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
[/code]
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

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

[i]Access denied for user 'ODBC'@'localhost' (using password: NO)[/i]

And yu are getting the secound error because your SQL syntax is wrong. This is what it should be:
[code]$validate = mysql_query("SELECT * FROM members WHERE username = '$username' AND password = md5('$password') AND verified = '1'");[/code]
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) [snapback]362614[/snapback][/div][div class=\'quotemain\'][!--quotec--]
How are you connecting to your MySQL database? As this the reaosn why you're getting this error:

[i]Access denied for user 'ODBC'@'localhost' (using password: NO)[/i]

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

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

//select database: PHPFreaks
mysql_select_db('PHPFreaks',$sql) or die(mysql_error());
?>
[/code]
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 [b]Eric Rosebrock[/b]
which I think is the owner of this website.

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

[code]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
[/code]

thank you
drunkpanda
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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.