Php图像无法显示包含错误

时间:2013-06-08 17:28:26

标签: php html

<!DOCTYPE html>

<head>
    <title>Display Picture</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
    <h1>A Picture from Our Collection</h1>
    <?php

    header("Content-type: image/jpeg");

    $id = $_GET["ident"];
    $pat = '/^[0-9]+$/';
    if(!preg_match($pat, $id)){
        exit; // broken image
    }
    $mysqli = new mysqli('localhost','root','9876543210','student13');
    $query = "select image from Picys where ident=$id";

    $result = $mysqli->query($query);

    $err = $mysqli->error;
    if(!empty($err)){
        exit;
    }

    $row = $result->fetch_array(MYSQLI_NUM);
    $bytes = $row[0];

    echo $bytes;
    ?>
    <hr />
    <h2>Tags</h2>
    <?php
    $stmt->close();
    $stmt = $mysqli->prepare("select Tagstr from PicyTags where Picid=?");
    $stmt->bind_param('s',$id);
    $stmt->execute();
    $stmt->bind_result($tag);
    $count = 0;
    while($stmt->fetch()){
        if($count==0){
            echo "<bold>Existing tags:</bold>";
        }
        $count++;
        echo "$tag<br />";
    }
    $mysqli->close();
    ?>
    <br />
    <h3>Add tag</h3>
    <p>You may add tags that characterize the contents of this picture.</p>
    <form action="./AddTag.php?ident=<?php echo $id ?>" method="POST">
        <fieldset>
            <legend>Your tag</legend>
                <input type="text" size="16" maxlength="16" />
        </fieldset>
        <input type="submit" value="Add Tag" />
    </form>
</body>

我无法显示数据库中的图片。我哪里错了?假设你是正确的

并且来自ADD标签<h3>没有任何东西可以显示出来。我的输出只是一个

<h1>A Picture from Our collection</h1>

在我的浏览器中!什么都没有出来

1 个答案:

答案 0 :(得分:2)

您已经发送了带有HTML标记的回复,然后尝试更改标题。在将任何内容输出到浏览器之前,应更改标题。