473,383 Members | 1,874 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,383 software developers and data experts.

post of fetched value fails

I have a MySql db, in which I search for values to populate a selection
box, as follows :

<select size="1" name="customer">
<option selected="selected">(not queried)</option>
<?php while($nt=mysql_fetch_array($result2)){
echo "<option value=$nt[customer]>$nt[customer]</option>\n";}
?>
</select>

This works fine, all the customers appear with their complete names,
including spaces if there are.

When I do a submit of the php page containing this part of code and in
this page I do a

$customer=$_POST['customer'];

then the value of $customer is cutted to the first <blank(space)
encountered.

E,g, : if in the selection box the customer name John Smith appears,
then I get in the result page after the submission as customer=John

When I make a selection box, with fixed populated values (so values not
fetched from the db) then after the submission, I get the correct info
(values are not cutted to the first space).

Is there anybody out there that can give a solution for this strange
(to me) behaviour ? It would be uttermost appreciated !

Oct 6 '06 #1
11 1237
rukkie wrote:
I have a MySql db, in which I search for values to populate a selection
box, as follows :

<select size="1" name="customer">
<option selected="selected">(not queried)</option>
Hi Rukkie,

That is wrong.
selected="selected" in nonsense.

If you want to select an option in a selectbox, you only use the word
SELECTED, and don't give it a value.

You'll have to produces something like this:
<SELECT name="customer">
<OPTION value="bla1">bla1
<OPTION value="bla2" SELECTED>bla2
<OPTION value="bla3">bla3
</SELECT>

In your code none of the options have a value.

I would advise you to FIRST learn how HTML and FORMS works, then start PHP.

Regards,
Erwin Moller

<?php while($nt=mysql_fetch_array($result2)){
echo "<option value=$nt[customer]>$nt[customer]</option>\n";}
?>
</select>

This works fine, all the customers appear with their complete names,
including spaces if there are.

When I do a submit of the php page containing this part of code and in
this page I do a

$customer=$_POST['customer'];

then the value of $customer is cutted to the first <blank(space)
encountered.

E,g, : if in the selection box the customer name John Smith appears,
then I get in the result page after the submission as customer=John

When I make a selection box, with fixed populated values (so values not
fetched from the db) then after the submission, I get the correct info
(values are not cutted to the first space).

Is there anybody out there that can give a solution for this strange
(to me) behaviour ? It would be uttermost appreciated !
Oct 6 '06 #2
rukkie wrote:
<?php while($nt=mysql_fetch_array($result2)){
echo "<option value=$nt[customer]>$nt[customer]</option>\n";}
?>
[...]
When I make a selection box, with fixed populated values (so values not
fetched from the db) then after the submission, I get the correct info
(values are not cutted to the first space).

Is there anybody out there that can give a solution for this strange
(to me) behaviour ? It would be uttermost appreciated !

What's the difference between the PHP generated HTML and the one with
fixed populated values?

I'm guessing PHP does

<option value=John Smith>John Smith</option>

whereas the fixed value is

<option value="John Smith">John Smith</option>

Notice the quotes on the second line?

--
File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot
Oct 6 '06 #3
Erwin Moller:
selected="selected" in nonsense.
"Full" attribute specifications are valid in both HTML and XHTML.
XHTML actually requires them, since attribute minimisation is not
allowed. I don't know how seriously you should take the somewhat dated
claim that 'many user agents only recognize the minimized form of
boolean attributes and not the full form' (HTML4.01, sec. B.3.4).

The problem is that the attribute value isn't quoted:

| echo "<option value=$nt[customer]>$nt[customer]</option>\n";}

In HTML only Name characters (i.e., [a-zA-Z0-9._:-]) can occur
unquoted, and in XHTML all attribute values must be quoted. Browser
error recovery probably means the first Name token is taken as the
value, so anything after the first non-Name character is ignored.

--
Jock

Oct 6 '06 #4
Thanks for all the replies .....

The problem is solved, it was indeed a "quotes" problem

The code that works is :

<select size="1" name="customer">
<option selected="selected">(not queried)</option>
<?php while($nt=mysql_fetch_array($result2)){
echo "<option
value=\"$nt[customer]\">$nt[customer]</option>\n";} ?>
</select>

Note the \" in the option value statement ....

Oct 6 '06 #5

Erwin Moller wrote:
>
I would advise you to FIRST learn how HTML and FORMS works,
then start PHP.
That's not a very nice way to tell someone they are wrong.

The long form of attributes has been allowed since AT LEAST html 3.0. You
can verify this by going to http://www.w3.org/MarkUp/html3/html3.dtd and
reading the doctype. Hint: text search for "nowrap" and "selected". Both
of them allow the default value of "nowrap" and "selected", respectively.
This is a fall-over from SGML, and EVERY browser since Netscape 3.2 has
supported it.
Oct 6 '06 #6
ZabMilenko:
The long form of attributes has been allowed since AT LEAST html 3.0.
Yes. In fact HTML has always allowed "full" attribute specifications.

Attribute specification minimisation - e.g., <OPTION selected- is an
optional feature, indicated by SHORTTAG YES in the SGML declaration.
EVERY browser since Netscape 3.2 has supported it.
That's a big claim.

According to HTML4.01 (now 7 years old), 'many user agents only
recognize the minimized form of boolean attributes and not the full
form'.

--
Jock

Oct 6 '06 #7
rukkie wrote:
[...]
echo "<option
value=\"$nt[customer]\">$nt[customer]</option>\n";} ?>

Note the \" in the option value statement ....
You can do that or use single quotes to quote the value

echo "<option value='$nt[customer]'>$nt[customer]</option>\n";

--
File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot
Oct 6 '06 #8
ZabMilenko wrote:
>
Erwin Moller wrote:
>
I would advise you to FIRST learn how HTML and FORMS works,
then start PHP.
>

That's not a very nice way to tell someone they are wrong.
Hi,

True,

I didn't mean it that harsh as it sounded.
Sorry rukkie!

Regards,
Erwin Moller
Oct 6 '06 #9

Yes you are right. It is a fairly big claim, and I could very well be wrong
about it.

I was kind of basing it off of IE3, Netscape3, Mosaic 2.1, and Opera 2.1,
all of which came out in 1996. HTML 3 was written in 1997 if I recall
correctly. Netscape was largely responsible for the changes from HTML2 to
3, so I kind of used them as a milestone. Since HTML4.0 was already on the
drawing board when HTML3 came out, most browsers shot for compliance at that
level.

The three browsers I can't say for sure on are AOL's bundled browser circa
1997 (before they bundled IE3), Apple Safari, and the Lynx browser.

Mosaic seems to be the only one with sporadic support for the commonly found
short attributes (particularly select disabled). And I honestly only used
it myself a few times.

When I read W3Cs claim in the 4.01 specification, I tend to think they are
talking about some very arcane user agents. In 1999, there were only a few
real popular browsers (the wars were basically over), but other agent types
were emerging (such as the Libretto/CE handhelds, the Palm wannabes and PCS
telephones).
Anyways, I take back what I said. It is better worded as: Almost every
user agent since Netscape 3.2 has supported it.


us*********@john.dunlop.name wrote:
>EVERY browser since Netscape 3.2 has supported it.

That's a big claim.

According to HTML4.01 (now 7 years old), 'many user agents only
recognize the minimized form of boolean attributes and not the full
form'.
Oct 6 '06 #10
Pedro Graca wrote:
rukkie wrote:
> <?php while($nt=mysql_fetch_array($result2)){
echo "<option value=$nt[customer]>$nt[customer]</option>\n";}
?>

[...]
>>When I make a selection box, with fixed populated values (so values not
fetched from the db) then after the submission, I get the correct info
(values are not cutted to the first space).

Is there anybody out there that can give a solution for this strange
(to me) behaviour ? It would be uttermost appreciated !

What's the difference between the PHP generated HTML and the one with
fixed populated values?

I'm guessing PHP does

<option value=John Smith>John Smith</option>

whereas the fixed value is

<option value="John Smith">John Smith</option>

Notice the quotes on the second line?
No, no difference at all, if it's coded correctly. If you view the
source in your browser, you should see:

<option value="John Smith">John Smith</option>

in either case.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Oct 6 '06 #11
Jerry Stuckle wrote:
Pedro Graca wrote:
>rukkie wrote:
>> echo "<option value=$nt[customer]>$nt[customer]</option>\n";}
// ----------------------------??-----------??
>I'm guessing PHP does

<option value=John Smith>John Smith</option>
No, no difference at all, if it's coded correctly.
Right! But the OP wasn't coded correctly.

--
File not found: (R)esume, (R)etry, (R)erun, (R)eturn, (R)eboot
Oct 6 '06 #12

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

Similar topics

3
by: zorro | last post by:
Hello there, I'm really stumped... I'm fetching a web page with a script and parsing it. There is a problem because the response inserts '8 1ff8' in random places. For example, I get things...
5
by: Phil Powell | last post by:
I cannot fathom this one.. for some cracked reason, one of my forms is totally OK and the other is apparently nonexistent according to both HTML and Javascript. The second form never submits...
0
by: Hitchkas | last post by:
I posted this question in PocketPC newsgroup with no answer. Hopefully somebody in this newsgroup can help me. I have problem with HTTP post in Compact Framework. The code below is a function...
23
by: Bjorn | last post by:
Hi. Every time i post data in a form the contents are being checked for validity. When i click the back-button, all data is gone and i have to retype it. It's obvious that only a few or none of...
2
by: =?Utf-8?B?cGhlbmdsYWk=?= | last post by:
I am not sure really how to explain this but here goes. I am creating some new web services and I want to be able to post data like the following: <Data> <some value>1</some value> <more...
5
by: =?Utf-8?B?QWxleCBNYWdoZW4=?= | last post by:
I am trying to create ASPX code which will allow me to redirect a user to another site with POST data. I figure that the best way to do this is with JavaScript to the client. Here's what I'm doing:...
3
by: Ifoel | last post by:
Hi all pls help me How to know "HOW MANY SECOND" we fetched the rows of the record MySQL via Visual Basic 6...? Sample: 321 rows Fetched in 0,234s -> i need this field to load on the FORM...
1
by: preejith | last post by:
Error Code : 1329, No data - zero rows fetched, selected, or processed. MYSQL I am getting the following error while running a stored procedure in mysql5.0 Error Code : 1329 No data - zero rows...
5
by: zoomcart.com | last post by:
Hello and thanks in advance for your help. I have code below that posts form data to a cgi scripted shopping cart and it works great on my mac/firefox browser, but it doesn't work on ibm/netscape...
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.