473,379 Members | 1,337 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,379 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 11452
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 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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.