Jump to content

Flash Builder -- PhP -- MySQL: UTF8 encoding


Wimmerke

Recommended Posts

In attachment is the code I generated from Flex Builder:

 

My issue is that the UTF8 (coding of the MySQL database) isn't correctly interpreted, the solution is to use : $stmt = mysqli_prepare($this->connection, "SET NAMES UTF8;");

But I don't know how to enter it in this syntax?

It is I think the: $stmt = mysqli_prepare($this->connection, "SELECT * from $this->tablename");

that has to be modified, but how? Really searching a long time on the correct syntax, but without any result...

 

Please help,

 

thanks a lot

Wimmerke

 

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/223974-flash-builder-php-mysql-utf8-encoding/
Share on other sites

SET NAMES UTF8 is an actual mysql query that you need to execute separately from your other queries (you can also use mysqli_set_charset().) Since the complete query is under your control, there's no point in using prepared statements to execute it. You can use mysqli_query().

 

It would actually be best to do this right after you make the connection to the database server.

 

 

  • 10 months later...

@Wimmerke: this is how I solved it:

 

public function getAllOznamy() {

$stmt2 = mysqli_prepare($this->connection, "SET NAMES 'utf8'");

$stmt3 = mysqli_prepare($this->connection, "SET CHARACTER SET 'utf8'");

$stmt = mysqli_prepare($this->connection, "SELECT * FROM $this->tablename");

$this->throwExceptionOnError();

 

mysqli_stmt_execute($stmt2);

mysqli_stmt_execute($stmt3);

mysqli_stmt_execute($stmt);

$this->throwExceptionOnError();

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.