drunkpanda Posted April 7, 2006 Share Posted April 7, 2006 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 pl1I have tired to google the error but I couldn't find the solution can somebody help me with it thank you drunkpanda Quote Link to comment https://forums.phpfreaks.com/topic/6826-access-denied-for-user-odbclocalhost-using-password-no/ Share on other sites More sharing options...
wildteen88 Posted April 7, 2006 Share Posted April 7, 2006 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 Link to comment https://forums.phpfreaks.com/topic/6826-access-denied-for-user-odbclocalhost-using-password-no/#findComment-24841 Share on other sites More sharing options...
drunkpanda Posted April 8, 2006 Author Share Posted April 8, 2006 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: PHPFreaksmysql_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 Quote Link to comment https://forums.phpfreaks.com/topic/6826-access-denied-for-user-odbclocalhost-using-password-no/#findComment-24971 Share on other sites More sharing options...
wildteen88 Posted April 8, 2006 Share Posted April 8, 2006 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 Link to comment https://forums.phpfreaks.com/topic/6826-access-denied-for-user-odbclocalhost-using-password-no/#findComment-25010 Share on other sites More sharing options...
drunkpanda Posted April 9, 2006 Author Share Posted April 9, 2006 [!--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 16Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\wamp\www\PHPFreaks\login.php on line 16Access 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 Quote Link to comment https://forums.phpfreaks.com/topic/6826-access-denied-for-user-odbclocalhost-using-password-no/#findComment-25223 Share on other sites More sharing options...
txmedic03 Posted April 12, 2006 Share Posted April 12, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/6826-access-denied-for-user-odbclocalhost-using-password-no/#findComment-26063 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.