07-08-2009, 04:33 AM
|
#1 (permalink)
|
|
The Visitor
Join Date: Jul 2009
Posts: 2
Thanks: 0
|
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 
|
|
|
|