I've a table where in a column is defined as nam char(75) default null. Let us say the name is 'American Bush'. The name is picked up from the table and displayed correctly in the dropdown menu in the form. But when it is passed on to another mysql table, the data is truncated as 'American' only. The second part of the string 'Bush' is truncated. If the two words of the string is concatenated with either an underscore or a full-stop or a dash, to make it seem as a single word, it is picked up fine. Why not space between two words. Beats me. I've seen replies on this forum stating that this is an html problem and the value is to be within quotes for it to be displayed properly. My problem is not with display on my browser but the value picked up for passing on to another table which is truncated. Any ideas anyone?
Data truncated on passing a value from a drop down menu.
Collapse
X
-
Hey.
Could you show us the HTML used for the drop-down? (After it is processed by PHP. From your browser.)
The most likely explanation for this is that you left out the quotes for the value attribute.
[code=html]// Passes only: "American" to the receiving page, even
// tho it displays: "American Bush" in the browser.
<option value=American Bush>American Bush</option>
// Passes and displays: "American Bush"
<option value="American Bush">American Bush</option>[/code]
If you leave them out, the HTML parser takes "American" as the vale of the value attribute, and assumes "Bush" is the name of another attribute. (How is the HTML parses supposed to know the space in the text is supposed to be a part of the text?)Comment
-
in simple word whenever you adding any option tag like
you should add double quotes whenever you providing any valueCode:<option value=hello world>Hello world</option>
Example
Code:<option value =hello world>hello world</option> <!--Wrong Way--> <option value ="hello world">hello world</option> <!--Correct Way-->
Comment
-
Dear Atli,
the code used by me for display of the drop down is as under.
Am actually picking up the value of the name from a table which has the structure as nam varchar(75) default null. The display in the drop-down appears in full i.e., "American Bush". But the value passed from this drop-down's display is not in full when inserted into another table, it appears as "American" with "Bush" truncated. Hope I made myself clear.Code:$qry2=mysql_query("select * from BORW_MAST order by nam"); <font color=brown>Name : <select name=nam> <?php print "<option value=''></option>"; while($row=mysql_fetch_row($qry2)) {print "<option value=$row[1]>$row[1]</option>"; } ?> </select>Comment
-
still you have the same problem which is described by atliCode:1. $qry2=mysql_query("select * from BORW_MAST order by nam"); 2. 3. <font color=brown>Name : 4. <select name=nam> 5. 6. <?php 7. print "<option value=''></option>"; 8. while($row=mysql_fetch_row($qry2)) 9. {print "<option value=$row[1]>$row[1]</option>"; 10. } 11. ?> 12. </select>Comment
Comment