Tag Archives: utf-8

php screws up utf-8 charachters from mysql database using mysqli

I have some chinese characters (e.g. 中文(简体)) stored in a mysql database with content type utf8_bin.
I am pulling from the database with this code:

if($stmt = $mysqli->prepare("SELECT c_color FROM colors")){
   $stmt->execute();
   $stmt->bind_result($ccolor);
   $stmt->store_result();
   if($stmt->fetch()){
       //$ccolor is filled with 

Continue reading

Tagged , , , , | Leave a comment

php display chinese characters SET NAMES 'utf8' not working

I’m trying to work with a database that I got but I can’t display chinese characters in it. The database was actually a MS Access file first, that I converted into mysql with a program. Anyway, many rows have chinese… Continue reading

Tagged , , | Leave a comment

Search tamil fonts in mysql and php

How to search tamil fonts and retrieve data from mysql and show the result using php?… Continue reading

Tagged , , , , | Leave a comment

Code to Text (PHP, languages)

When I submit a post with AJAX that is not in English, I will get something similar to %u4F60%u662F%u5982%u4F55%u505A%uFF1F
What can I do to fix this in PHP? I’ve tried utf8_decode… and doesn’t work.
I’m submitting the text with AJAX Continue reading

Tagged , , , | Leave a comment

Why is this preg_match() code returning true in PHP CLI and false in Apache

I’m trying to validate some Arabic text encoded in UTF-8 and running into unexpected results in PHP 5.3.8. Running the following snippet through CLI returns true and false through Apache.

var_dump(preg_match("/[[:alnum:]]/i", "عايش لهدف"));

I have mbstring.func_overload set to 7 and Continue reading

Tagged , , , | Leave a comment

MongoDB [MongoRegex] query: working on localhost but empty results on server

I use MongoRegex to find cities starting with first characters of users’s input:

$search  = new MongoRegex('/^'.$_POST['search'].'/');
$results = iterator_to_array( $mongodb->cities->find(array('_id'=>$search)) );

On localhost (Windows) $results contains array of cities, but on server (Debian) $results is always = empty array. Continue reading

Tagged , , , | Leave a comment

UTF8 troubles in a php contact form

Here is my contact function :

public static function contact_anon()
{
    $form = new Form('contact_anon');

    $form->field('email', 'text', array
    (
        'max_length'    =>  45,
        'valid_email'   =>  true
    ));

    $form->field('message', 'textarea', array
    (
        'max_length'    =>  400,
        'min_length'    =>  25
    ));

    if($data = $form->validate())
    

Continue reading

Tagged , , , , | 1 Comment

Charset issues when storing rss data into a mysql table

At the moment I’m reading rss feeds that may be encoded in any character type, using simplexml_load_file();…
These feeds are then looped through in php and some parts are inserted into a mysql database that is utf8 with all tables Continue reading

Tagged , , , , | Leave a comment

Replace character ā with it's html entity ā

I’m having a really hard time trying to replace a certain character with it’s entity equivalent. I tried to str_replace the character “ā” but it just wont work! I can’t see why. The code I use:

$content = str_replace('ā', 'ā',$content);

Continue reading

Tagged , , | Leave a comment

Allow only (English & Arabic) in UTF-8 code

I am looking for a regex to change all non-english and/or arabic into underscore “_”
Currently I have the following code which works but I think that I’ve got the wrong unicode
range as it allows Chinese & other languages… Continue reading

Tagged , , , | 1 Comment
12 pages