SET NAMES command fails with access denied
29,320
Solution 1
Setting the php file
to UTf-8
seemed to work.
Solution 2
Don't mix use of the mysql_*
and mysqli_*
functions. Instead of
mysql_query("SET NAMES 'utf8'");
use
$dbc->set_charset('utf8');
Solution 3
I think there is no problem in connection there is the the problem that you are using the mysql_query
and you are connecting with mysqli_connect
.
So use the mysqli_query
to execute the query.
Author by
snookian
Updated on September 30, 2020Comments
-
snookian over 3 years
I'm trying to insert an accented
e
into a mysql database following this example. Using this:mysql_query("SET NAMES 'utf8'");
throws:
Warning: mysql_query() [function.mysql-query]: Access denied for user 'ODBC'@'localhost'
Its not connecting to the database:
DEFINE ('DB_USER', 'user'); DEFINE ('DB_PASSWORD', 'pword'); DEFINE ('DB_HOST', 'localhost'); DEFINE ('DB_NAME', 'test1'); $dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);