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
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.

 

 

Link to comment
Share on other sites

  • 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();

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.