Access denied for user 'ODBC'@'localhost' (using password: NO) | Familiar Sight | | Join Date: Oct 2008
Posts: 128
| | |
i hav downloaded php script from a site but while running it gives error
Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\wamp\www\forum\db.class.inc.php on line 29
i use this for my connection and works well
$conn=mysql_connect("localhost","root","");
while this doesnt work
function db($localhost='localhost',$database='ncstd',$usern ame='root',$password='')
kindly help as i m new to php
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,658
| | | re: Access denied for user 'ODBC'@'localhost' (using password: NO) Quote:
Originally Posted by kkshansid while this doesnt work
function db($localhost='localhost',$database='ncstd',$usern ame='root',$password='') then you should check, whether db() works correctly.
| | Familiar Sight | | Join Date: Oct 2008
Posts: 128
| | | re: Access denied for user 'ODBC'@'localhost' (using password: NO) - function db($localhost='localhost',$database='ncpul1',$username='root',$password=''){
-
$this->localhost=$localhost;
-
$this->database=$database;
-
$this->username=$username;
-
$this->password=$password;
-
$this->conn=mysql_connect($this->localhost,$this->username,$this->password);//line29
-
mysql_select_db($this->database,$this->conn);
-
}
i dont think there is any error in this function
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,658
| | | re: Access denied for user 'ODBC'@'localhost' (using password: NO)
just to make sure… how do you call db()?
| | Familiar Sight | | Join Date: Oct 2008
Posts: 128
| | | re: Access denied for user 'ODBC'@'localhost' (using password: NO)
on index page after including connection file function call as - $db=new db($DB_LOCALHOST,$DB_DATABASE,$DB_USERNAME,$DB_PASSWORD);
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,658
| | | re: Access denied for user 'ODBC'@'localhost' (using password: NO)
is $DB_USERNAME a variable or a constant?
|  | Moderator | | Join Date: Jun 2007 Location: York, England, with wolves.
Posts: 4,948
| | | re: Access denied for user 'ODBC'@'localhost' (using password: NO)
In your first example, you say it works when user = root. However, the error is saying that you're connecting as 'ODBC' (I assume that's no username). So you're doing something wrong.
|  | Moderator | | Join Date: Aug 2008 Location: Leipzig, Germany
Posts: 3,658
| | | re: Access denied for user 'ODBC'@'localhost' (using password: NO)
I suspect that’s the username used when no username ("", null) was given. if the username is indeed saved as DB_USERNAME (you* hardly name variables uppercase) it would be the explanation.
* at least the ones who read the naming convention
|  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,471 network members.
|