473,323 Members | 1,570 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

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_value">

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 11435
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_value">

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_value">
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_value = $_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_not.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_value">

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.uswrote:
On Sep 18, 10:24*am, Jeff <jeff@spam_me_not.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_value">
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_not.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_value">

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,
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_not.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_value">

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,

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_value">

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_value">

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_value">

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
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...
2
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...
1
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
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...
2
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...
2
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...
3
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...
10
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.......
2
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.......
6
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.