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

Jonathan Schwartz jschwartz at exit445.com
Tue Dec 9 15:21:52 MST 2008


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

At 9:12 PM +0100 12/9/08, Gjermund Gusland Thorsen wrote:
>Does this work?
>
>http://user:pass@server:port/fmi/xml/FMPXMLRESULT.xml?-db=DB.fp7&-lay=web&-max=50&-sortfield.1=Alpha%20Beta&-sortorder.1=ascend&Alpha+Beta=John+Smith&-find
>
>or this:
>
>http://user:pass@server:port/fmi/xml/FMPXMLRESULT.xml?-db=DB.fp7&-lay=web&-max=50&-sortfield.1=Alpha+Beta&-sortorder.1=ascend&Alpha+Beta=John+Smith&-find
>
>or this:
>
>http://user:pass@server:port/fmi/xml/FMPXMLRESULT.xml?-db=DB.fp7&-lay=web&-max=50&-sortfield.1=Alpha%20Beta&-sortorder.1=ascend&Alpha%20Beta=John%20Smith&-find
>
>ggt
>
>2008/12/9 Gjermund Gusland Thorsen <ggt667 at gmail.com>:
>>  I am asking a question about this:
>> 
>>http://user:pass@server:port/fmi/xml/FMPXMLRESULT.xml?-db=DB.fp7&-lay=web&-max=50&-sortfield.1=Alpha%20Beta&-sortorder.1=ascend&Alpha+Beta=John+Smith&-find
>>
>>  Does this parameter: Alpha+Beta=John+Smith
>>  or this parameter work: -sortfield.1=Alpha%20Beta
>>
>>  There is no urlencode() or str_replace().
>>
>>  ggt
>>
>>  2008/12/9 Jonathan Schwartz <jschwartz at exit445.com>:
>>>  I'll answer your question when you answer my question. ;-)
>>>
>>>  What do I test and where? I don't whether you are referring to urlencode or
>>>  str_replace, and where in the script to use the functions.
>>>
>>>
>>>  J
>>>
>>>  At 8:04 PM +0100 12/9/08, Gjermund Gusland Thorsen wrote:
>>>>
>>>>  Please answer the question: What works?
>>>>
>>>>  is "+" or "%20" good?
>>>>
>>>>  ggt
>>>>
>>>>  2008/12/9 Jonathan Schwartz <jschwartz at exit445.com>:
>>>>>
>>>>>   Sorry to be dense, but where exactly in the code is urlencode or
>>>>>  str_replace
>>>>>   used?
>>>>>
>>>>>   J
>>>>>
>>>>>   At 7:40 PM +0100 12/9/08, Gjermund Gusland Thorsen wrote:
>>>>>>
>>>>>>   What works? + is good? or %20 is good?
>>>>>>
>>>>>>   %20%20%20%20%20 can be in sequence, while +++++ sometimes turns out as
>>>>>>   just 1 space...
>>>>>>
>>>>>>   2008/12/9 Jonathan Schwartz <jschwartz at exit445.com>:
>>>>>>>
>>>>>>>   OK.
>>>>>>>
>>>>>>>   Now how do I fix my problem?
>>>>>>>
>>>>>>>   The previous suggestions were to use str_replace, but there are a
>>>>>>>   variety of
>>>>>>>   places to do this, and I'm running out of combinations.
>>>>>>>
>>>>>>>   In the form?
>>>>>>>   In the fx.php AddDBParam?
>>>>>>>
>>>>>>>   Plus...what characters am I replacing with what?
>>>>>>>
>>>>>>>   For reference, the application here is my super duper search page
>>>>>>>  engine
>>>>>>>   that serves multiple db's and web sites simultaneously.  I need to get
>>>>>>>   this
>>>>>>>   right so that it works for everyone because I can no longer skirt the
>>>>>>>   issue
>>>>>>>   by requiring fieldnames with no spaces.
>  >>>>>>
>>>>>>>   I'm not giving up until I crack this thing.
>>>>>>>
>>>>>>>   J
>>>>>>>
>>>>>>>   At 6:40 PM +0100 12/9/08, Gjermund Gusland Thorsen wrote:
>>>>>>>>
>>>>>>>>   &20 is ascii value of the space character
>>>>>>>>   + is urlencoding of the space character
>>>>>>>>
>>>>>>>>   ggt
>>>>>>>>
>>>>>>>>   2008/12/9 Jonathan Schwartz <jschwartz at exit445.com>:
>>>>>>>>>
>>>>>>>>>   Hi Folks,
>>>>>>>>>
>>>>>>>>>   I still haven't 100% licked the spaces-in-field-names issue yet.
>>>>>>>>>   Now
>>>>>>>>>   I
>>>>>>>>>   realize why, and I'm just looking for a sanity check.
>>>>>>>>>
>>>>>>>>>   It appears that spaces in file names produces different behavior
>>>>>>>>>   depending
>>>>>>>>>   whether the FMP query is a FIND parameter versus a SORT parameter.
>>>>>>>>>
>>>>>>>>>   It boils down to this:
>>>>>>>>>
>>>>>>>>>   FMP Field Definition:           Alpha Beta
>>>>>>>>>   Alpha Beta Field Value: John Smith
>>>>>>>>>   Browser POST:           Alpha_Beta (Apache Server replaces space
>>>>>>>>>  with
>>>>>>>>>   underline)
>>>>>>>>>   FMP FIND URL:           Alpha+Beta (FX (?) replaces space with "+"
>>>>>>>>>  in
>>>>>>>>>   URL)
>>>>>>>>>   FMP SORT FIELD URL:     Alpha%20Beta  (FX (?) replaces space with
>>>>>>>>>   "%20"
>>>>>>>>>   in
>>>>>>>>>   URL)
>>>>>>>>>
>>>>>>>>>   Here's an actual URL that shows the existence of both methods in the
>>>>>>>>>   same
>>>>>>>>>   URL:
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> 
>>>>>>>>>http://Admin:Admin@000.000.000.000:80/fmi/xml/FMPXMLRESULT.xml?-db=DB.fp7&-lay=web&-max=50&-sortfield.1=Alpha%20Beta&-sortorder.1=ascend&Alpha+Beta=John+Smith&-find
>>>>>>>>>
>>>>>>>>>   So...
>>>>>>>>>   The html form displays the field name with the space.
>>>>>>>>>   Apache POST  replaces the space with an underline.
>>>>>>>>>   FX/PHP replaces the space in a FIELD NAMEwith a "+"
>>>>>>>>>   FX/PHP replaces the space in a SORT NAMEwith a "%20"
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>   Argh.
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>   If this is correct, then a single remedy won't work.  A different
>>>>>>>>>   remedy
>>>>>>>>>   has
>>>>>>>>>   to be applied to SEARCH fields versus SORT fields.
>>>>>>>>>
>>>>>>>>>   I did get suggestions last time I posted this problem, but each time
>>>>>>>>>  I
>>>>>>>>>   applied the remedy, it broke the other half. Now I see why.
>>>>>>>>>
>>>>>>>>>   Before I move forward....any comments?
>>>>>>>>>
>>>>>>>>>   J
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>   --
>>>>>>>>>   Jonathan Schwartz
>>>>>>>>>   Exit 445 Group
>>>>>>>>>   jonathan at exit445.com
>>>>>>>>>   http://www.exit445.com
>>>>>>>>>   415-370-5011
>>>>>>>>>   _______________________________________________
>>>>>>>>>   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
>>>>
>>>>   >>>
>>>>>>>
>>>>>>>   --
>>>>>>>   Jonathan Schwartz
>>>>>>>   Exit 445 Group
>>>>>>>   jonathan at exit445.com
>>>>>>>   http://www.exit445.com
>>>>>>>   415-370-5011
>>>>>>>   _______________________________________________
>>>>>>>   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
>>>>>
>>>>>
>>>>>   --
>>>>>   Jonathan Schwartz
>>>>>   Exit 445 Group
>>>>>   jonathan at exit445.com
>>>>>   http://www.exit445.com
>>>>>   415-370-5011
>>>>>   _______________________________________________
>>>>>   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
>>>
>>>
>>>  --
>>>  Jonathan Schwartz
>>>  Exit 445 Group
>>>  jonathan at exit445.com
>>>  http://www.exit445.com
>>>  415-370-5011
>>>  _______________________________________________
>>>  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


-- 
Jonathan Schwartz
Exit 445 Group
jonathan at exit445.com
http://www.exit445.com
415-370-5011


More information about the FX.php_List mailing list