TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   add special characters to DB? (http://www.talkphp.com/absolute-beginners/4704-add-special-characters-db.html)

arale 07-08-2009 04:33 AM

add special characters to DB?
 
Hello,

I have a question about preg_match, I couldn’t understand how it works. Code below allow me to add word without space and special characters. I want to add words for another language, which contains spaces and special character like (â, ế, đ…) but not (?, #, %...etc). So my questions are:

1. I set DB to utf8_general_ci, is it correct? To show special unicode characters

2. How to modifly code below to make it adds words with space and special unicode characters? I think it is about preg_match, but I don’t know how it works and how to edit it :-/

PHP Code:

function add_new_word($word){
    if (
preg_match('/^[a-zA-Z]+$/'$_POST['word'])) {
        
$word $_POST['word'];
    } else {
        echo 
'Illegal parameters!';
        exit();
    }

    if (
add_word($word)) {
        echo 
"<p>Successfully added word! </p>";
    } else {
        echo 
"<p>Failure! Unable to add word! </p>";
    }
    echo 
"<b>Word:</b> $word<br/>";


Thank you :-)


All times are GMT. The time now is 09:01 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0