开发者

Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO)

开发者 https://www.devze.com 2023-04-09 18:07 出处:网络
I\'m using XAMPP on Windows 7. and when I try to open a login.php of current project I get this error Warning: mysql_query() [function.mysql-query]: Access denied for user \'ODBC\'@\'localhost\' (us

I'm using XAMPP on Windows 7. and when I try to open a login.php of current project

I get this error

Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO) in E:\xampplite\htdocs\newfule\mcp\clientlist.php on line 19

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in E:\xampplite\htdocs\newfule\mcp\clientlist.php on line 19

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in E:\xampplite\htdocs\newfule\mcp\clientlist.php on line 21
Sorry No entries for the Records of Student ......

this is config file

<?php

$link = mysql_connect('127.0.0.1', 'root', '');
if (!$link) {
   die('Not connected : ' . mysql_error());
}

// make foo the current db
$db_selected = mysql_select_db('fueldb', $link);
if (!$db_selected) {
   die ('Can\'t use foo : ' . mysql_error());
}
?>

This开发者_开发问答 is one warning is at phpmyadmin

Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO)


Using phpmyadmin you cannot have a user with an empty password which instead is allowed in mysql.


The error doesn't seem to be in the config file. ODBC is the default user when none is specified, so since everything seems good in the config file it appears it's either not being included before the call to mysql_query or that the mysql_query call itself is being done wrong.

Without more code there's no real way to know.


i think you don't have problem with config file.i think problem with adding a config file or including a config file.i suggest u to check link that include or add config file.


Use localhost instead of 127.0.0.1

127.0.0.1 uses TCP instead of unix sockets

Also stop using mysql for PHP. It has been removed. Use mysqli or pdo


Your error and your config file are not appling the same users

Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost' (using password: NO)

Error about query the user "ODBC" from host "localhost"

mysql_connect('127.0.0.1', 'root', '');

Connecting with the user 'root' to '127.0.0.1'

¿Is your configuration applied? It seems that "clientlist.php" is using other $link resource

Also take in cosideration that the users in mysql user table contains by default the host reference. This meants that root@localhost could be correct to access without password but root@127.0.0.1 could be denied.

You could view in the user table of the "mysql" database the registered users, if they have password and the host (or hosts) allowed. Each user could appear more than once if the host is different. Also is possible to use the character "%" in the host to allow all hosts or a subnet (but i dont recommend this for production environments)

In all cases is recommended to create a proper user and assing privileges to the desired database to operate it.


try to given access table to user :

grant all On [tabelName] to [userName];

example

grant all On mysql.* to root;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号