我试图在 xml 中显示 select 的结果。但是,当我列出带有 blob 图像的结果时,我收到以下错误:此页面包含以下错误:第 33 行第 27 列的错误:编码错误下面是页面的呈现直到第一个错误。
我不知道出了什么问题... MySQL 中的字段类型是 blob。
<?php
header('Content-type: text/xml');
mysql_connect('localhost', 'root', 'test');mysql_select_db('test');
if(isset($_GET['id']) && $_GET['id'] != '')
{
if($_GET['id'] == '0'){$sql = 'SELECT * FROM CDUsers';}
else{$sql = 'SELECT * FROM cdusers WHERE id = '.$_GET['id'];}
}
$result = mysql_query($sql) or die(mysql_error());
$num = mysql_num_rows($result);
if($num != 0)
{?>
<CDUsers>
<?php while($user = mysql_fetch_assoc($result))
{?>
<user>
<id><?php echo $user['id'];?></id>
<name><?php echo $user['name'];?></name>
<surname><?php echo $user['surname'];?></surname>
<location><?php echo $user['location'];?></location>
<email><?php echo $user['email'];?></email>
<password><?php echo $user['password'];?></password>
<gender><?php echo $user['gender'];?></gender>
<foto><?php echo $user['foto'];?></foto>
<tipo><?php echo $user['tipo'];?></tipo>
</user>
<?php }//?>
</CDUsers>
<?php }else
{?>
<CDUsers>
<user>
vazio
</user>
</CDUsers>
<?php }
?>