[FX.php List] Spaces in Field Names...one more time with gusto

Derrick Fogle derrick at fogles.net
Tue Dec 9 15:51:01 MST 2008


I'll point out that this is probably a heck of a lot of rote code to  
write for what appears to be a generic engine for anyone's database.  
Then again, doing this means that there must be some kind of 'special  
character' management for all FMP field names. As another pointed out,  
spaces won't be the only problem. I'd start with the previously  
recommended urlencode() function, and go from there.

On Dec 9, 2008, at 4:39 PM, Troy Meyers wrote:

> J,
>
> This is what I was alluding to in my prior post.
>
> I recommend that you DON'T treat input fields as same-name entities  
> as FileMaker fields.
>
> Have:
> <input name="alphabeta" />
> ...in your form instead, then in the PHP that sets up the query,  
> have something like:
> if (isset($_POST['alphabeta'])) {
>     $your_find->AddDBParam('Alpha Beta','=='.$_POST['alphabeta'])
> }
>
> This way you not only keep the difference between form field names  
> and values divorced from the FileMaker field names --until you want  
> them associated-- but you also give away fewer clues about how to  
> hack your pages, and have much stronger control over what can and  
> can't be done with your page.
>
> -Troy
>
>
>> ggt,
>>
>> Each one of the URLs below work.  That is, when the command to FMP is
>> issued to via URL all is fine, whether the space in the field name is
>> replaced with "%20" or "+", FMP responds appropriately.
>>
>> So that's not the problem.
>>
>> The problem is the step before: When fields with spaces in their   
>> names
>> are POSTed via a FORM,  the resulting POST is automatically   
>> replacing
>> the space with an underline:
>>
>> From the Form:
>>
>> 		<input name="Alpha Beta">
>>
>> From the POST Array:
>>
>> 	Array
>>
>> (
>>
>> 	[Alpha_Beta] => John Smith
>>
>> )
>>
>> 	Notice "Alpha Beta" (with space)  field name is POSTed as
>> "Alpha_Beta" (with underline).
>>
>> I'm observing this using a print_r($_POST);  command.
>>
>> So, when I build an Fx.php  query, it does so with "Alpha_Beta" (with
>> underline) and an error 102 is produced because the field in FMP is
>> "Alpha Beta (no underline).
>>
>> That is the base problem.
>>
>> Not sure why I'm the only one with this problem.  I've always dealt
>> with the problem by redefining FMP Field names to eliminate  
>> spaces.  No
>> longer have that luxury.
>>
>> So...where do insert urlencode or str_replace?
>>
>> I tried this:
>>
>> 	<input name =<?php urlencode('Alpha Beta');?>">
>>
>> and it did produce this POST:
>>
>> Array
>>
>> (
>>
>> 	[Alpha+Beta] => John Smith
>>
>> )
>>
>> But that post produced this URL, and of course failed with the same
>> 102 error (note the %2B):
>>
>> http://.....Alpha%2BBeta=John+Smith....
>>
>> I'm trying!
>>
>> J
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list


Derrick



More information about the FX.php_List mailing list