[FX.php List] Bad apostrophe character confounds FMP

Andrew Denman adenman at tmea.org
Tue Dec 11 09:27:24 MST 2007


I usually run everything that gets output to the page from a database
through htmlentites()
(http://us.php.net/manual/en/function.htmlentities.php), though I have PHP
5.2.3 which allows me to specify not to encode already encoded characters
(the 4th parameter).

If you have < PHP 5.2.3 you will have to know whether or not the data is
already encoded and if you need to encode it (in this case you do) otherwise
you get the entities printed out on your page. (ie: if you run &amp; through
htmlentities() without the 4th parameter, it will encode it to &amp;amp;)

Here's my code to apply it recursively to an array so it can be applied
directly to the data from the database:
function htmlentities_array($x){
   if (is_array($x)) {return array_map('htmlentities_array', $x);}
   return htmlentities($x, ENT_QUOTES, "UTF-8", false);
}
...
$orders = $ordersQuery->DoFXAction(FX_ACTION_FINDALL);
$orders = htmlentities_array($orders);

If you have < PHP 5.2.3 you can use this:
function htmlentities_array($x){
   if (is_array($x)) {return array_map('htmlentities_array', $x);}
   return htmlentities($x, ENT_QUOTES, "UTF-8");
}
...
$orders = $ordersQuery->DoFXAction(FX_ACTION_FINDALL);
$orders = htmlentities_array($orders);

Andrew Denman

-----Original Message-----
From: fx.php_list-bounces at mail.iviking.org
[mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of VanBuskirk,
Patricia
Sent: Tuesday, December 11, 2007 9:58 AM
To: FX.php Discussion List
Subject: RE: [FX.php List] Bad apostrophe character confounds FMP

Here's my code ... how would I encode it?

<SELECT name="Contact_Bldg" tabindex="5">
  <OPTION selected>NOT LISTED - Type in Below</OPTION>
  <?php

require_once('../FX/FX.php');

// configure a connection to FileMaker Server Advanced
$ordersQuery = new FX('www2.otc.fsu.edu', '80', 'FMPro7');
// set database and layout information
$ordersQuery->SetDBData('WEB_Forms', 'Ref_FSU_Buildings', 'all');
// set database username and password
$ordersQuery->SetDBUserPass('xuserx', 'xpassx');
// retrieve all records in this database available to the current user
$ordersQuery->AddSortParam('ListForWeb', 'ascend');
$orders = $ordersQuery->DoFXAction(FX_ACTION_FINDALL);
	foreach ($orders as $contact) {
    echo "                <option>{$contact['ListForWeb']}\n";

}
?>
</SELECT>


-----Original Message-----
From: fx.php_list-bounces at mail.iviking.org
[mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of Dale Bengston
Sent: Tuesday, December 11, 2007 10:54 AM
To: FX.php Discussion List
Subject: Re: [FX.php List] Bad apostrophe character confounds FMP

Valid HTML would call for the & character to be encoded as &amp; in  
the <option> code.

Dale

On Dec 11, 2007, at 6:59 AM, VanBuskirk, Patricia wrote:

> I went to that validator site for one of my forms and had several of  
> the
> following type errors.  The list it is referencing is pulled directly
> from a FMP value list.  Many of them came up with red x's which I'm
> assuming is a critical error.  Short of changing the entire database
> (this list pulls from an Oracle database), is there a way to fix this?
>
> Line 1064, Column 49: reference to entity "MICROSCOPY" for which no
> system identifier could be generated.
>                <option>COM129-ANATOMY&MICROSCOPY LABS (D09) - 313 WEST
> STADIUM DRIVE
>
>
> -----Original Message-----
> From: fx.php_list-bounces at mail.iviking.org
> [mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of Tim 'Webko'
> Booth
> Sent: Monday, December 10, 2007 6:44 PM
> To: FX.php Discussion List
> Subject: Re: [FX.php List] Bad apostrophe character confounds FMP
>
>
> On 11/12/2007, at 10:12 AM, Gjermund Gusland Thorsen wrote:
>
>> "Re: what the standard requires."
>>
>> Where did you read that? w3.org?
>
> http://www.w3.org/TR/xhtml1/#docconf for XHTML 1.0
>
> http://www.w3.org/TR/html401/struct/global.html#version-info for HTML
> 4.01
>
> I'll also note, to be picky, that there are actually a number of
> syntax errors in your example page:
>
http://validator.w3.org/check?uri=http%3A%2F%2Fwww.file-making.com%2Fsam
> ples%2Fadd.php&charset=%28detect+automatically 
> %29&doctype=Inline&group=0
>
> Cheers
>
> Webko
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list

_______________________________________________
FX.php_List mailing list
FX.php_List at mail.iviking.org
http://www.iviking.org/mailman/listinfo/fx.php_list
_______________________________________________
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