PHP字段在第一个空格处被截断


PHP field is truncated at the first space

我有一个HTML表单,它将两个字段写入MySql数据库。那部分很好用。现在,我正试图用该数据库中的值预先填充表单上的两个字段。这样,当数据保存后刷新屏幕时,或者当用户在后续访问中显示页面时,该字段将预先填充数据库中的值。其中一个变量字段是$home_text。我暂时将$home_text的值回显到页面上,它会显示字段中的所有单词。但是,当我尝试在Input的Value子句中使用$home_text时,它会截断第一个空格后的字段值。如何让HTML表单显示$home_text的整个值而不在第一个空格处截断?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body>
<form name="Form1" id="Form1" action="post_mess_age.php" method="post">
<?php
$servername = "localhost";
$username = "myUser";
$password = "myPassword";
$dbname = "myDBName";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT notice from notification where page = 'home' limit 1";
$result = mysqli_query($conn, $sql);
if (!$result) 
{
    echo 'Could not run query: ' . mysql_error();
    exit;
}
$row = mysqli_fetch_row($result);
echo $row[0] . "<br>";
$home_text = $row[0];
echo 'Home_text is :' . $home_text . "<br>";
mysqli_close($conn);
?> 
<table class="table_800">
    <tr>
    <td width="480" align="left">
        <input type="text" size="80" maxlength="400" 
        name="home_page_text" id="home_page_text"
        value=<?php echo $home_text?>" 
        style="background-color:#FFC" />
    </td>
    </tr>
</table>
</form>
</body>

看起来value属性在您的输入中缺少一个双引号,这可能是问题所在吗?

value=<?php echo $home_text?>" 
value="<?php echo $home_text?>"