Jump to content

Encoding of chars


wiggst3r

Recommended Posts

Hi

 

I'm writing an sms data capture script, which takes in details form an sms text message and inserts them into a mysql database.

I've also written a debug file, which checks the details that have been sent via sms, to make sure that there are no errors before it is inserted.

I have a problem. For some reason the _ and the @ signs are being replaced.

The output from the debug is:

name:test
email:test\0test.com
mobile:07777777777
nokia:y
model:n95
opt^Qin:n
comp^Qans:200

 

Any ideas what the problem is?

 

Thanks

 

 

Link to comment
https://forums.phpfreaks.com/topic/134042-encoding-of-chars/
Share on other sites

FILE NAME START: InboundSmsModel November 24, 2008, 2:30 pm
{

}
FILE NAME END: InboundSmsModelNovember 24, 2008, 2:30 pm
        FUNCTION START: parse_message
        {
                The message is []
                returning array
                FUNCTION START: debug_row
                {
                }
                FUNCTION END: debug_row
        }
        FUNCTION END: parse_message
        The value of POST is:
        FUNCTION START: debug_row
        {
                [gwnumber] => [353876498759]
                [smsc] => []
                [sender] => [447779298737]
                [time] => [2008-11-24 14:30:22]
                [data] => [name:test
email:test\0test.com
mobile:07777777777
nokia:y
model:n95
opt^Qin:n
comp^Qans:200]
        }
        FUNCTION END: debug_row
        The value of the message array is:
        FUNCTION START: debug_row
        {
        }
        FUNCTION END: debug_row

 

This is generated in part by:

 

function validate($field, $val)
        {
                //Called in the loop through the post-split array
                $ret = 'fail'; //default to fail
                //tests for the y/n m/f values are pretty accommodating - we simply check whether the field _contains_ a y or a n etc
                $field = strtolower($field);
                switch ($field)
                {
                        case 'name':
                                //pretty much anything goes - if it's printable or empty
                                if(ctype_print($val) || strlen($val) == 0)
                                //remove any commas
                                $ret = $val;
                                break;
                        case 'email':
                                //pretty much anything goes - if it's printable or empty
                                $v = new Validation;
                                if($v->valid_email($val))
                                {
                                        $ret = $val;
                                }
                                else
                                {
                                        $ret = '';
                                }
                                break;
                        case 'opt_in':
                                $val = strtolower($val);
                                if((strpos($val, 'y') !== false) || (strpos($val, 'w') !== false)||(strpos($val, 'x') !== false)||(strpos($val, 'z') !== false)|| (strpos($val, '9') !== false)){
                                        $ret = 1;
                                }
                                else{
                                        $ret = 0;
                                }
                                break;
                        case 'nokia':
                                $val = strtolower($val);
                                if((strpos($val, 'y') !== false) || (strpos($val, 'w') !== false)||(strpos($val, 'x') !== false)||(strpos($val, 'z') !== false)|| (strpos($val, '9') !== false)){
                                        $ret = 1;
                                }
                                else{
                                        $ret = 0;
                                }
                                break;
                        case 'model':
                                //pretty much anything goes - if it's printable or empty
                                if(ctype_print($val) || strlen($val) == 0)
                                //remove any commas
                                $ret = $val;
                                break;
                        case 'comp_ans':
                                //pretty much anything goes - if it's printable or empty
                                if(ctype_print($val) || strlen($val) == 0)
                                //remove any commas
                                $ret = $val;
                                break;
                        case 'mobile':
//take out spaces
                                $val = str_replace(' ', '', $val);
                                if((strlen($val) >= 8 && substr($val,0,1) == '0' && ctype_digit($val)) || (strlen($val) == 0))
                                {
                                        $ret = $val;
                                }
                                else
                                {
                                        $ret = '';
                                }
                                break;
                }
                debug("FOR FIELD [$field] the value was [$val] and returning [$ret]");
                return $ret;
        }
       

Link to comment
https://forums.phpfreaks.com/topic/134042-encoding-of-chars/#findComment-697824
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.