Jump to content

[SOLVED] Problem with HTML Form


bzptlx

Recommended Posts

I'm new here and if this has been asked and solved before I am sorry for the dupe. I am using PHP 5.2.4 with Apache 2 and MySql 5.0.45.

 

I am having a problem displaying data in an HTML for for updates. The data is truncated at the first space in the form field.

 

        For instance "The Beer Store" is displayed as "The".

 

If I display the data outside the form field (input type-text) it displays correctly so I know the pull from the database is working correctly.

 

Any ideas? TIA

Link to comment
https://forums.phpfreaks.com/topic/71532-solved-problem-with-html-form/
Share on other sites

Here is the code section. The one highlighted in green works properly but the one in red stops sidplay after the first space:

 

$query  = "SELECT * FROM location where idnum='1'";

$result = mysql_query($query);

 

while($row = mysql_fetch_array($result, MYSQL_ASSOC))

{

echo "<form>";

echo "<tr border=0>";

    echo "<td border=0>";

    echo "<div class=btxt>Name:&nbsp";

    echo "<input type=text size=50 value={$row['name']}>{$row['name']}</div>";

    echo "</td>";

echo "</tr>";

 

.......

Put quotes around the value of every parameter.

 

   echo "<input type=text size=50 value={$row['name']}>{$row['name']}</div>";

 

Is going to evaluate to

 

<input type=text size=50 value=The Beer Store>The Beer Store</div>

 

The browser is going to interpret this as an input tag with the value attribute set to The and two additional unknown attributes Beer and Store.

 

Change all your tags so they look like this.

 

   echo "<input type=\"text\" size=\"50\" value=\"{$row['name']}\">{$row['name']}</div>";

 

This way value will be set to The Beer Store instead of The.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.