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);
Don't mix use of the mysql_*
and mysqli_*
functions. Instead of
mysql_query("SET NAMES 'utf8'");
use
$dbc->set_charset('utf8');
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With