从MySql (PHP)传递到表单的截断数据

时间:2021-10-02 15:55:50

Below is a sample line of code from the HTML form that is created and the data is receives:

下面是创建并接收数据的HTML表单的代码示例行:

    Mission: <input readonly type='text' name='mission' value=".$mission.">

It works fine, but the data is truncated. For example, if the mission is "Mission Five", the "Five" gets cut off.

它工作得很好,但是数据被截断。例如,如果任务是“任务5”,“5”就会被切断。

2 个解决方案

#1


3  

Because you forgot quote your attributes. Your html will be

因为你忘了引用你的属性。html将

 <input [..snip..] value=Mission Five>
                      ^----^---attribute + value
                                   ^---new attribute with no value

Try

试一试

Mission [..snip..] value='" . $mission ."'>
                         ^---------------^

producing

生产

Mission [..snip..] value='Mission Five'>

#2


1  

The value field is missing quotes

值字段缺少引号

Mission: <input readonly type='text' name='mission' value=".$mission.">

should be more like

应该更像

Mission: <input readonly type='text' name='mission' value='".$mission."'>

This assumes that you are echoing this out as a string with PHP and the string is enclosed in double quotes initially ( which is how it appears due to ".$mission." )

这就假定您正在用PHP将这个字符串作为一个字符串进行响应,并且该字符串最初是用双引号括起来的(这是它出现的原因,因为“.$mission”。)

#1


3  

Because you forgot quote your attributes. Your html will be

因为你忘了引用你的属性。html将

 <input [..snip..] value=Mission Five>
                      ^----^---attribute + value
                                   ^---new attribute with no value

Try

试一试

Mission [..snip..] value='" . $mission ."'>
                         ^---------------^

producing

生产

Mission [..snip..] value='Mission Five'>

#2


1  

The value field is missing quotes

值字段缺少引号

Mission: <input readonly type='text' name='mission' value=".$mission.">

should be more like

应该更像

Mission: <input readonly type='text' name='mission' value='".$mission."'>

This assumes that you are echoing this out as a string with PHP and the string is enclosed in double quotes initially ( which is how it appears due to ".$mission." )

这就假定您正在用PHP将这个字符串作为一个字符串进行响应,并且该字符串最初是用双引号括起来的(这是它出现的原因,因为“.$mission”。)