TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 07-08-2009, 04:33 AM   #1 (permalink)
The Visitor
Newcomer 
 
Join Date: Jul 2009
Posts: 2
Thanks: 0
arale is on a distinguished road
Confused 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
arale is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting special characters in LIKE (mySQL) ReSpawN Advanced PHP Programming 2 11-12-2012 07:44 AM
Special to plain characters ReSpawN Advanced PHP Programming 3 05-27-2009 10:33 AM
Unexpected characters in output Killswitch Absolute Beginners 2 12-20-2008 04:29 AM
Cleaning out unwanted characters Andrew General 6 10-20-2007 08:31 PM
Cryptography's Sodium Chloride Wildhoney Tips & Tricks 7 09-26-2007 05:19 PM


All times are GMT. The time now is 07:11 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design