473,662 Members | 2,551 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

spaces in $_REQUEST (or $_GET, $_POST)

I have a legacy database table that has spaces in the field names.

So I have a form that looks like this:

<input type="text" name="name with space" value="some_val ue">

on the server I have:

$field_name = 'name with space';

$my_form_value = $_POST[$field_name];

That doesn't work, I never see the form element. How do I get around this?

Note that I have many tables like this and I'm generating the edits
programaticaly.

Jeff
Sep 18 '08 #1
9 11488
Jeff wrote:
I have a legacy database table that has spaces in the field names.

So I have a form that looks like this:

<input type="text" name="name with space" value="some_val ue">

on the server I have:

$field_name = 'name with space';

$my_form_value = $_POST[$field_name];

That doesn't work, I never see the form element. How do I get around this?
What does enumerating the $_POST array say (the keys, that is)? I know
periods are replaced with underscores. So spaces may be replaced with
underscores as well.

Best regards,
--
Willem Bogaerts

Application smith
Kratz B.V.
http://www.kratz.nl/
Sep 18 '08 #2
..oO(Jeff)
I have a legacy database table that has spaces in the field names.

So I have a form that looks like this:

<input type="text" name="name with space" value="some_val ue">
Such names are invalid:

| ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
| followed by any number of letters, digits ([0-9]), hyphens ("-"),
| underscores ("_"), colons (":"), and periods (".").
>on the server I have:

$field_name = 'name with space';

$my_form_val ue = $_POST[$field_name];

That doesn't work, I never see the form element. How do I get around this?
Fix the names.

Micha
Sep 18 '08 #3
On Sep 18, 10:24*am, Jeff <jeff@spam_me_n ot.comwrote:
* I have a legacy database table that has spaces in the field names.

* *So I have a form that looks like this:

<input type="text" name="name with space" value="some_val ue">

on the server I have:

$field_name = 'name with space';

$my_form_value = $_POST[$field_name];

That doesn't work, I never see the form element. How do I get around this?

Note that I have many tables like this and I'm generating the edits
programaticaly.

* *Jeff
Can you not just put in a translator? IE for outgoing html forms,
replace the " " in the field with an underscore, then when reading the
form and putting information in the database, replace the "_" in the
field name with an underscore.

Bill H
Sep 18 '08 #4
On Sep 18, 8:02*pm, Bill H <b...@ts1000.us wrote:
On Sep 18, 10:24*am, Jeff <jeff@spam_me_n ot.comwrote:
* I have a legacy database table that has spaces in the field names.
* *So I have a form that looks like this:
<input type="text" name="name with space" value="some_val ue">
on the server I have:
$field_name = 'name with space';
$my_form_value = $_POST[$field_name];
That doesn't work, I never see the form element. How do I get around this?
Note that I have many tables like this and I'm generating the edits
programaticaly.
* *Jeff

Can you not just put in a translator? IE for outgoing html forms,
replace the " " in the field with an underscore, then when reading the
form and putting information in the database, replace the "_" in the
field name with an underscore.

Bill H
Wouldn't you want to replace the "_" with a space?
Sep 18 '08 #5
Bill H wrote:
On Sep 18, 10:24 am, Jeff <jeff@spam_me_n ot.comwrote:
> I have a legacy database table that has spaces in the field names.

So I have a form that looks like this:

<input type="text" name="name with space" value="some_val ue">

on the server I have:

$field_name = 'name with space';

$my_form_val ue = $_POST[$field_name];

That doesn't work, I never see the form element. How do I get around this?

Note that I have many tables like this and I'm generating the edits
programaticaly .

Jeff

Can you not just put in a translator? IE for outgoing html forms,
replace the " " in the field with an underscore,
I used a "+" to replace the spaces in the forms and when building the
key for $_POST. I usually use underscores to replace spaces but I didn't
want to use it here as I wanted some symbol that I wouldn't see
otherwise, yet had some meaning.

I don't know what naming conventions Access users use, but these
tables have been driving me crazy. Field and table names are
uppercase and have spaces in them. Primary keys may or may not be there
and if they are they aren't autoincrement. Unfortunately, it's all
mission critical stuff.

Jeff

then when reading the
form and putting information in the database, replace the "_" in the
field name with an underscore.

Bill H
Sep 18 '08 #6
Jeff wrote:
Bill H wrote:
>On Sep 18, 10:24 am, Jeff <jeff@spam_me_n ot.comwrote:
>> I have a legacy database table that has spaces in the field names.

So I have a form that looks like this:

<input type="text" name="name with space" value="some_val ue">

on the server I have:

$field_name = 'name with space';

$my_form_valu e = $_POST[$field_name];

That doesn't work, I never see the form element. How do I get around
this?

Note that I have many tables like this and I'm generating the edits
programatical y.

Jeff

Can you not just put in a translator? IE for outgoing html forms,
replace the " " in the field with an underscore,

I used a "+" to replace the spaces in the forms and when building the
key for $_POST. I usually use underscores to replace spaces but I didn't
want to use it here as I wanted some symbol that I wouldn't see
otherwise, yet had some meaning.
After further thought, it didn't seem like + was legal in a form
field name, so I went with the underscore.

Jeff
>
I don't know what naming conventions Access users use, but these
tables have been driving me crazy. Field and table names are
uppercase and have spaces in them. Primary keys may or may not be there
and if they are they aren't autoincrement. Unfortunately, it's all
mission critical stuff.

Jeff

then when reading the
>form and putting information in the database, replace the "_" in the
field name with an underscore.

Bill H
Sep 18 '08 #7
*** Jeff escribió/wrote (Thu, 18 Sep 2008 10:24:56 -0400):
I have a legacy database table that has spaces in the field names.

So I have a form that looks like this:

<input type="text" name="name with space" value="some_val ue">

on the server I have:

$field_name = 'name with space';

$my_form_value = $_POST[$field_name];

If you print the contents of $_POST:

print_r($_POST) ;

You'll see the actual name:

Array
(
[name_with_space] =some_value
)

The reason is that PHP used to create a local variable for each form value
(now it's optional an deprecated) and you can't have a variable with spaces
on its name.
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor en cubitos: http://www.demogracia.com
--
Sep 18 '08 #8
Michael Fesser:
.oO(Jeff)
<input type="text" name="name with space" value="some_val ue">

Such names are invalid:

| ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
| followed by any number of letters, digits ([0-9]), hyphens ("-"),
| underscores ("_"), colons (":"), and periods (".").
No, the value of the name attribute of the form element is declared as
CDATA, not as a NAME token, so pretty much anything goes, including
spaces.

But, as the FAQ says, PHP would convert these spaces to underscores.

http://www.php.net/manual/en/faq.html.php

--
Jock
Sep 18 '08 #9
..oO(John Dunlop)
>Michael Fesser:
>.oO(Jeff)
><input type="text" name="name with space" value="some_val ue">

Such names are invalid:

| ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
| followed by any number of letters, digits ([0-9]), hyphens ("-"),
| underscores ("_"), colons (":"), and periods (".").

No, the value of the name attribute of the form element is declared as
CDATA, not as a NAME token, so pretty much anything goes, including
spaces.
Indeed, had forgotten that. Thanks for the correction.

I would still avoid them.

Micha
Sep 19 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
22279
by: Cal Lidderdale | last post by:
I've built a OutOfOffice calendar in PHP. Each month is a standalone table, the first column being the person's name. Then N cells, one for each day of the month. And I have 2 Calendars: a nice looking read-only and a working calendar where each "day" is "<input name=$empidx$doy type=text size=1..." that allows a supervisor to edit V(aca), S(ick) etc. and then save to a MySql DB. It was working fine until I was asked to add 9 new names...
2
5317
by: Angie | last post by:
Hello everybody, I have an osCommerce shopping cart on my site, which is an open-source product that uses php. I'm very new to php. I also have an online scheduling application that I outsourced to a third party, which resides on a different server. I asked my scheduling provider if there was anyway I could use my osCommerce php registration for thier registration so I could avoid having visitors to the site register and sign-in twice,...
1
2965
by: vishal | last post by:
hi vishal here. could anyone tell me what is difference between get-post and head-put method of passing data between diffrent different web pages thxs for help in advance..............
3
11285
by: Paul M | last post by:
Hi Sorry if this is posted in the wrong group but I'm brand new to this area. Basically I've got to post some XML documents to an external server using HTTP web request (POST, not GET) and be able to receive files back. I've got the XML file generated and checked over, but I just dont know how to go about the post process. I've got a feeling I'm supposed to create a form in my ASP application with an action which points at the URL I've...
2
2656
by: Ron Peleg, Creo | last post by:
Hi, I know you can call the WS methods using HTTP GET/POST, simply by providing the method name in the URL and appending the parameters as the method requires. However, we would like to use this call method to invoke the Beginxxx/Endxxx functions that are generated for each method. Is this possible? Using the plain Begin-function-name in the URL did not work (although using POST/GET is enabled and works for the 'sync' calls).
2
5030
by: David T. Ashley | last post by:
Are GET and POST parameters required to have values, i.e. are either of these legal? http://www.mydomain.com/index.php?this&that http://www.mydomain.com/index.php?this=&that= In my application, I have a GET/POST parameter that is significant just by its presence (it doesn't need a value), and rather than say this=1&that=1 I was wondering if it is legal to specify them without values.
3
4364
by: ziana | last post by:
Hi all, What is the disadvantages of using GET/POST/COOKIES in php? What's the different when i use global below included in each files?, i can pass all the parameter without $_POST etc. and register_global = OFF. >>>global.php: <?php /** * @version $Id: globals.php,v 1.7 2005/01/24 17:48:18 troozers Exp $
10
3228
by: rup | last post by:
Hello, This is my first application on socket programming in vc++. I am facing problem that how to make connection to server, & make GET/POST request by HTTP. Please help me. Its urgent.... Thanks
2
5969
by: rup | last post by:
Hello, This is my first application on socket programming in vc++. I am facing problem that how to make connection to server, & make GET/POST request by HTTP. Please help me. Its urgent.... Thanks
6
1377
by: jake | last post by:
I think I may why this is happening but I am a little fuzzy as to what the solution should be as I am somewhat new to all of this. My simplified code that generates the error is: public static string getCartCookieValue() { if (Request.Cookies != null) {
0
8344
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8857
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8764
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8633
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5654
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1993
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.