I have a project developed in PHP 5.4.35 using CakePHP, When I insert some unicode string into database,     Example : Bệnh suy giảm trí nhớ   After insert into database, this is the database content of record :      Bá»‡nh suy giáº£m trÃ­ nhá»›   If I use php 5.4 it display perfectly on website :     Bệnh suy giảm trí nhớ   I also develop an api in json format for this project and the api response when I get this data is:  B\u1ec7nh suy gi\u1ea3m tr\u00ed nh\u1edb When client (mobile client) get this data and display, it is displayed perfectly same as website.  But when I move to a hosting with php 5.3.23, it is displayed on website just like on database:     Bá»‡nh suy giáº£m trÃ­ nhá»›      And the api response : B\u00e1\u00bb\u2021nh suy gi\u00e1\u00ba\u00a3m   tr\u00c3\u00ad nh\u00e1\u00bb\u203a It is dislayed : Bá»‡nh suy giáº£m   trÃ­ nhá»› on mobile device (which displayed perfectly if I use php5.4   for api)   ;  then I tried to use utf8_decode function of php after get it from database and this is result:  utf8_decode($record);      B��?nh suy giảm trí nh��?   I thought that maybe this string was encoded before inserted to mysql in php5.4 and then decoded right after get it from the database, but in php5.3 it keep the string when insert and get from database. and the encoder, decoder of utf8 in php 5.3 and 5.4 is different??? I guest.   I'm using cakephp 2.5.3 and it use PDO to insert and get data from database I've tried all the way to change charset, collate .... but it take no effect like :  PDO -> exec ('SET names utf8'), PDO -> exec (' Set names utf8 collate utf8_unicode_ci'); .... I've also set the charset of header, html meta tags....  my database use utf8_unicode_ci collation in both environment no different in database version It's just I found no way to resolve the problem, so if anyone know about this please give me some solutions Thanks
326
I'm setting up a new server and want to support UTF-8 fully in my web application. I have tried this in the past on existing servers and always seem to end up having to fall back to ISO-8859-1.  Where exactly do I need to set the encoding/charsets? I'm aware that I need to configure Apache, MySQL, and PHP to do this — is there some standard checklist I can follow, or perhaps troubleshoot where the mismatches occur?  This is for a new Linux server, running MySQL 5, PHP, 5 and Apache 2.
99906
One of the responses to  suggested that I should make sure my database can handle UTF-8 characters correctly. How I can do this with MySQL?
33014
I have the string which that encoded in .  How do I decode this in php?  Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum felis = pede, vestibulum et, ullamcorper in, ultrices eget, metus. Suspendisse in n= ulla. Sed justo. Donec dapibus auctor neque. Pellentesque faucibus ante nec=  metus. Vivamus feugiat, velit rhoncus semper suscipit, libero augue venena= tis leo, nec ornare nulla elit eget diam. Nullam sollicitudin.
69369
The keyboard I am trying to create has a lot of Unicode and looks like this:   Being unsuccessful with the following tutorial:    (There are a few errors in the tutorial, and it uses imprecise language such as "Cutting" things instead of "Deleting" them, and it is formatted strangely)   I was wondering if anybody would be so kind to provide a better tutorial with step by step instructions?
3156
Here are the args for my query :  $args = array(     'post_type' =&gt; 'news',     'meta_query' =&gt; array(         array(             'key' =&gt; 'topics',             'value' =&gt; 'sports',         )     ) );   This works when topics is a string, but not when it is an array. I'd like this query to work when topics is for example array( 'sports', 'nonprofit', etc. )  Is there a way to build meta queries with arrays as a meta_key ?
3752
I have PHP configured so that magic quotes are on and register globals are off.  I do my best to always call htmlentities() for anything I am outputing that is derived from user input.  I also occasionally seach my database for common things used in xss attached such as...  &lt;script   What else should I be doing and how can I make sure that the things I am trying to do are always done.
86157
I was trying to add the column of MYSQL Timestamp to the Database Table, the Query seems to be working correctly in mysql console.But when I execute the same in db_query() the following error is thrown.     Failed: PDOException: SQLSTATE[42000]: Syntax error or access   violation: 1067 Invalid default value for 'last_update_date': ALTER   TABLE stores ADD last_update_date TIMESTAMP NOT NULL DEFAULT   '0000-00-00 00:00:00';; Array ( ) in store_update_7100() (line 254 of   /var/www/slocamo_app/sites/all/modules/store/store.install).   Is the Query.  ALTER TABLE  `stores` ADD  `last_update_date` TIMESTAMP NOT NULL DEFAULT  '0000-00-00 00:00:00');
77077
I was creating a table in SQL Server CE and realized it doesn't support varchar.   Looking this up, I found that "non-Unicode text columns (varchar, char, text) and smallmoney are not supported; although nvarchar, nchar, ntext, and money are supported" as .  Is this true? Why is this, exactly? It would seem that a compact database would support data types that take less bytes to store...I'm assuming it takes more space to save the Unicode characters.   What is the reasoning behind this?
76414
Background: This question relates to versions of Delphi below 2009 (ie without Unicode support built in). I have a specification that requires me to transmit a Unicode encoded string over a TCP connection but I do not have Delphi 2009.   Question Is there a single function or very small library (I don't need too much bulk) that I can use to encode a single string into UTF-8 immediately prior sending over the wire? As a second part of my question: if there are UTF-8 encoded strings being sent back as a response, I guess I would then need another function to get it back into a Delphi string format. I understand the limitations of such Unicode support in this way.
47900
In my little age with WordPress, I've seen WordPress itself and its friendly plugins are using PHP serialize() in storing data into db in many cases. But in a recent search I found a serious community support for the json_encode() over the serialize().     And I personally tested an associative array with both of 'em, that shows:  serialize() stores 342 chars json_encode() stores 285 chars  Why I'm asking this? I'm on a project while I'm going to store repeating meta fields to a post. Where:  Data would be basically in English, but sometimes can be Bengali Data would be associative array, 3 level deep (I hope I understood levels correctly):   array(     1 =&gt; array(         'key'=&gt;'value',         'key2'=&gt;'value'     ),     2 =&gt; array(         'key'=&gt;'value',         'key2'=&gt;'value'     ) )  I've checked the postmeta table's meta_value field it's a longtext,  a length of 4,294,967,295 chars (4GB). So I need a robust solution into storing things.
44862
I have a problem binding booleans using mysqli_stmt::bind_param in PHP5. The SQL query is the following: insert into `nvp_notes` (subject,messageid,receivedate,read) values (?,?,?,?)  Where 'read' is a tinyint, either 0 or 1, as I've had issues with bit using mysqli. So the types that I list in bind_param are: $stmt-&gt;bind_param('sdsd', ...);  I've also tried 'sdsb' and 'sdss' but nothing seems to work, and I always get the message:  Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement  When I remove the read field in the statement everything works fine. I've run out of ideas with this one. Surely bind_param works with booleans?
22248
I have Drupal running on MariaDB 5.5.33. When I run update.php (after upgrade to Drupal 7.28 from Drupal 6) I get an error:     Failed: PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'webdb.location_country' doesn't exist: CREATE TABLE {location_country} ( code CHAR(2) NOT NULL COMMENT 'Primary Key: Two letter ISO Country Code', name VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'Full Country Name ', PRIMARY KEY (code) ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COMMENT 'Country data managed by location.module.'; Array ( ) indb_create_table() (line 2720 of /home/web/public_html/includes/database/database.inc).   When I try to run command     CREATE TABLE {location_country} ( code CHAR(2) NOT NULL COMMENT 'Primary Key: Two letter ISO Country Code', name VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'Full Country Name ', PRIMARY KEY (code) ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COMMENT 'Country data managed by location.module.';   in phpMyAdmin I get an error     #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '{location_country} ( code CHAR(2) NOT NULL COMMENT 'Primary Key: Two letter IS' at line 1   But I wasn't able to find out where is the problem.
93719
I'm struggling with the design of new database that has to use a different collation (Y Collation) than the SQL Server Instance default collation (X Collation). I'm looking for potential problems.  Temp Tables by default will be created with X Collation so any joins on text data types will fail unless I create temp table with Y collations on columns.  What about SQL Server string functions: REPLACE, SUBSTRING, etc.? Will they always be returned in X collation? What about when I use REPLACE(...) COLLATE Y? Do you see any potential data loss or maybe any different problems?
76738
I have a webserver administration question. In this website:   All PHP generated pages contain the following line:  &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" /&gt;   But this is somehow disregarded probably via the php-apache processing and the page displays in browsers with an UTF-8 header. As a result of that question marks (�) are shown in the page text instead of accented characters (éáöőóüűúí). I tested this in Firefox, IE, Chrome and Seamonkey.  The strangest in this phenomenon, that this symptom started only yesterday, after I upgraded my server to Debian 8.0 Jessie from 7.0 Wheezy. During the upgrade I also upgraded all other packages as well, including apache, php, and so on, and selected "yes" for overwriting config files with factory default ones. After this I fine-tuned my config files to have everything the way I like, but I did not find a way to fix this. Before the upgrade, the page displayed just fine.  Here is a screenshot, where you can see that Firefox sees the "charset=iso-8859-2" definition, but still displays the page with UTF-8 encoding.    My suspicion is, that this is a server configuration issue, but it could also be, that one part of the processing component (Apache, php) changed due to the upgrade in some way, resulting this strange behavior. The problem is, I can't pinpoint, what could possibly cause this problem.  Can anyone solve this mistery? What could be possibly going wrong during the processing of the page?
48211
Im using smarty and mysql_real_escape_string() for user input, and when I insert some code with ' or " , and lookup in phpmyadmin it shows without backslashes.  When I get record from DB i doesn't have backslashes also. But when I just pass escaped string without inserting into the db it is backslashed.  Shouldn't it add slashes, insert with them and then I would  strip them when i would output? Or am I missing something?
71900
In languages like Java and C#, strings are immutable and it can be computationally expensive to build a string one character at a time.  In said languages, there are library classes to reduce this cost such as C# System.Text.StringBuilder and Java java.lang.StringBuilder.  Does php (4 or 5; I'm interested in both) share this limitation?  If so, are there similar solutions to the problem available?
93580
I'm working with a MySQL database that has some data imported from . The data contains non- characters (em dashes, etc.) as well as hidden carriage returns or line feeds. Is there a way to find these records using MySQL?