[FX.php List] Checking POST data for content.

DC dan.cynosure at dbmscan.com
Tue Mar 14 13:31:07 MST 2006


Hi Rob,

I think i undersatnd what you are asking... you have to make sure you 
are comparing the same data.

Take a look at the manual page for html_entity_decode().

http://us2.php.net/manual/en/function.html-entity-decode.php

where i found this code comment:
---------------------------------
This function seems to have to have two limitations (at least in PHP 4.3.8):

a) it does not work with multibyte character codings, such as UTF-8
b) it does not decode numeric entity references

a) can be solved by using iconv to convert to ISO-8859-1, then decoding 
the entities, than convert to UTF-8 again. But that's quite ugly and 
detroys all characters not present in Latin-1.

b) can be solved rather nicely using the following code:

<?php
function decode_entities($text) {
    $text= html_entity_decode($text,ENT_QUOTES,"ISO-8859-1"); #NOTE: 
UTF-8 does not work!
    $text= preg_replace('/&#(\d+);/me',"chr(\\1)",$text); #decimal notation
    $text= preg_replace('/&#x([a-f0-9]+);/mei',"chr(0x\\1)",$text); 
#hex notation
    return $text;
}
?>

HTH
---------------------------------

mvh,
dan


Rob H. Christensen had written:
> I have a page, which function is both to display the data from the database,
> and to allow to edit those data. I have a php scripts which field by field
> compares the "old" data in the  fields in the database with the "old" or
> "new" data in the POST array, before the data is made into an AddDBParam in
> the edit script. Also a variable is set for logging, if the data has
> changed. 
> Both parts are equally important.
> Because of the language (Danish) there are some problems in doing this. It
> seems that FileMaker and PHP each have their own and different definitions
> for some of the characters, which in HTML are escaped as "&aelig;",
> "&oslash;# and "&aring;" OR "&#230", "&#248" qnd "&#229" and likewise for
> the Uppercase characters.
> This results in the script deciding there is a difference between the "old"
> data in the database and the "old" data in the POST array, thus creating a
> log entry for the unchanged data.
> 
> The script part which decides this is as:
> 
> if($findJobData['Deadline'][0]!==$_POST['Deadline'])
> {
>                    
> $editJob->AddDBParam('Deadline', $_POST['Deadline']);
>                    
> $Deadline_log="Deadline: " . $_POST["Deadline"] . ". ";
> }
> 
> 
> $Deadline_log is made part of a later $LOGNEW
> 
> ($LOGNEW=$LOGOLD . [some other variables] . "\n" . $Date . ": New Deadline"
> . $Deadline_log; ) 
> 
> My question is: Is there an easier way to compare these "old" and "new"
> entries in the form, which does not conflict with the differences in
> expressing these odd characters?  Part of these entries are selected values
> in pop-up lists, part are text fields.  The only text unaffected seems to be
> the text in a textarea. The pages are used on Mac and PC, which also have
> different opinions about representing certain non standard characters.
> 
> Filemaker 6 Unlimited on Mac OS 10.3.8 with Apache 1.3.33 and PHP 4.3.10,
> using FX 3.1.
> 
> Rob
> 
> 
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
> 


More information about the FX.php_List mailing list