Jump to content

Saving UTF in sql via php - Help


Tuck

Recommended Posts

"-› ¿мαттнιαs? ‹-" is the string i set my sql db to be utf8_bin but well do  i have to replace some chars before saving it into sql i got str_replace() to replace ' with \' (this is just an example) could anyone show me :/

 

Saving it direct into database like that will be viewed correct with sql db viewer but, retrieving it with sql will display "-› ¿???????s? ‹-"

Link to comment
Share on other sites

I suspect the question should read something along the lines of "How do I succesfully store crylic characters in an SQL database? And how would I output this information?"

 

Have you checked the database with PHPMyAdmin to see if the characters appear correct? It's probable that the displaying isn't working properly because of the character encoding on the page your trying to echo the characters out to.

Link to comment
Share on other sites

I suspect the question should read something along the lines of "How do I succesfully store crylic characters in an SQL database? And how would I output this information?"

 

Have you checked the database with PHPMyAdmin to see if the characters appear correct? It's probable that the displaying isn't working properly because of the character encoding on the page your trying to echo the characters out to.

 

i tried to save them from phpmyadmin..

 

Read:

Saving it direct into database like that will be viewed correct with sql db viewer but, retrieving it with sql will display "-› ¿???????s? ‹-"

Link to comment
Share on other sites

So as I said the character encoding on the page isn't correct. You need to set the content type header, either by use of the header function or through HTML.

 

<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />

Link to comment
Share on other sites

So as I said the character encoding on the page isn't correct. You need to set the content type header, either by use of the header function or through HTML.

 

<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />

 

now displays "-� �???????s? �-"

Link to comment
Share on other sites

I did a quick search and came across somebody that claims this solved their problem using...

 

mysql_query("SET CHARACTER SET utf8");
mysql_query("SET NAMES utf8");

 

... which is a slight addition to nrobi's suggestion.

 

$result = mysql_query("SELECT * FROM `lottery` WHERE `STEAM`='${LSTEAM}' AND `ID`>'1'");

 

show me an example how i would include it there? :/

Link to comment
Share on other sites

:wtf: er....

mysql_query("SET CHARACTER SET utf8");
mysql_query("SET NAMES utf8");
$result = mysql_query("SELECT * FROM `lottery` WHERE `STEAM`='${LSTEAM}' AND `ID`>'1'");

 

though u ment it needed to be included in the mysql_query of result ;/ trying it now

Link to comment
Share on other sites

Personally i have

mysql_query("SET CHARACTER SET utf8");
mysql_query("SET NAMES utf8");

on the same place as connection to the database

 

Yer, that would obviously be more sensible than before each query. I wasn't intending to be literal.

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.