Mysql 从SQL查询回显逗号

Mysql 从SQL查询回显逗号,mysql,using,comma,Mysql,Using,Comma,我尝试了这个网站和谷歌,但我发现有人问如何在mySQL查询之间输出逗号。我的问题是mySQL查询本身包含逗号。我在一个MySQL查询中插入了一个值,其中包含逗号,看起来效果不错。奇怪的是,在一个页面上它显示得很好,包括逗号,但在另一个页面上,显示是这样的: 英语 实际值如下所示: 英语、德语 我知道,在某种程度上,这个问题被解释为需要分离的东西,但我真的不知道如何解决这个问题。以下是个人资料页面: $result=mysql_query("SELECT * FROM membersfromsit

我尝试了这个网站和谷歌,但我发现有人问如何在mySQL查询之间输出逗号。我的问题是mySQL查询本身包含逗号。我在一个MySQL查询中插入了一个值,其中包含逗号,看起来效果不错。奇怪的是,在一个页面上它显示得很好,包括逗号,但在另一个页面上,显示是这样的:

英语

实际值如下所示:

英语、德语

我知道,在某种程度上,这个问题被解释为需要分离的东西,但我真的不知道如何解决这个问题。以下是个人资料页面:

$result=mysql_query("SELECT * FROM membersfromsite WHERE    userusername='$sessionusername'");

while($row=mysql_fetch_array($result)){
echo "<p class='middle'>Username: " . $row['userusername'] . "<br>";
if (!$row['age'] )
{
echo "Age not specified.";
} 
else
{
echo "Age: " . $row['age'] ;
}

if(!$row['language'])
{
echo "<br>You haven't specified which languages you speak.";
}
else
{
echo "<br>Speaks these languages: " . $row['language'] . "</p>";
}

}
$result=mysql_query("SELECT * FROM membersfromsite WHERE userusername='$sessionusername'");

while($row=mysql_fetch_array($result)){

echo "<p class='middle'>Username: " . $row['userusername'] . "<br>";
echo "<form action='edittingprofile.php' method='post'>Age: <input name='ageform' type='text'";
if($row[age])
{
echo "value=$row[age]>";
}
echo "</input><br>Speaks these languages: <input name='languageform' type='text' ";
if ($row[language])
{

echo "value=$row[language])>";
}
echo "</input><br><input type='submit' value='edit'></p></form>";
}
$result=mysql\u查询(“从membersfromsite中选择*,其中userusername='$sessionusername'”);
while($row=mysql\u fetch\u数组($result)){
echo“

用户名:“.$row['userusername']”“
”; 如果(!$row['age'])) { echo“未指定年龄。”; } 其他的 { echo“Age:”.$row['Age']; } 如果(!$row['language'])) { echo“
您尚未指定您所说的语言。”; } 其他的 { echo“
说这些语言:“.$row['language']”“

”; } }
这很好,我的输出是:“荷兰语,英语”。所以插入逗号一点问题都没有。但我在编辑个人资料页面上有:

$result=mysql_query("SELECT * FROM membersfromsite WHERE    userusername='$sessionusername'");

while($row=mysql_fetch_array($result)){
echo "<p class='middle'>Username: " . $row['userusername'] . "<br>";
if (!$row['age'] )
{
echo "Age not specified.";
} 
else
{
echo "Age: " . $row['age'] ;
}

if(!$row['language'])
{
echo "<br>You haven't specified which languages you speak.";
}
else
{
echo "<br>Speaks these languages: " . $row['language'] . "</p>";
}

}
$result=mysql_query("SELECT * FROM membersfromsite WHERE userusername='$sessionusername'");

while($row=mysql_fetch_array($result)){

echo "<p class='middle'>Username: " . $row['userusername'] . "<br>";
echo "<form action='edittingprofile.php' method='post'>Age: <input name='ageform' type='text'";
if($row[age])
{
echo "value=$row[age]>";
}
echo "</input><br>Speaks these languages: <input name='languageform' type='text' ";
if ($row[language])
{

echo "value=$row[language])>";
}
echo "</input><br><input type='submit' value='edit'></p></form>";
}
$result=mysql\u查询(“从membersfromsite中选择*,其中userusername='$sessionusername'”);
while($row=mysql\u fetch\u数组($result)){
echo“

用户名:“.$row['userusername']”“
”; 呼应“年龄:”; } echo“
说这些语言:”; } 回声“

”; }
出于某种原因,输出为:

荷兰人


没别的了。有人知道这里出了什么问题吗?

2件事:首先,确保在
value
属性中引用字符串:
value=“{$row['language']}”
其次,使用
htmlspecialchars()
确保使用
entu QUOTES
选项对HTML转义。在输出到html时始终使用
htmlspecialchars()
<代码>回显“值=”。htmlspecialchars($row['language'],entu引号)。“'”所发生的事情是,
荷兰语和英语之间有一个空格,但是由于
value=
attr没有被引用,所以在HTML中不能被识别为单个值。非常感谢!我在查看我的PHP代码,但您的简单解决方案使其工作正常:D