-2

ユーザー名が挿入された後、ユーザーの表示画像がデータベースから取得される関数を作成しています。しかし、私は自分のコードでいくつかの問題に直面しています。是非チェックしてみてください^^ ありがとうございます。

<?php
include("connection.php");

$name = $_SESSION['login_username']; // login_username is test123, this is $_SESSION from another .php file
$_SESSION['name'] = $storename;


echo '<img src="display2.php"width="90" height="90"/>'; //this is how i display my picture
?>

Display.php(動かない)

mysql_select_db($database) or die("Can not select the database: ".mysql_error());

$storename = $_SESSION['name']; // is there an error with my $_session statement?
$name = (string)$storename; 

if(!isset($name) || empty($name)){
     die("Please select your image!");

}else{


$query = mysql_query("SELECT * FROM customerdetail WHERE customer_username='$name'");
$num_row = mysql_fetch_array($query);
$content = $num_row['image'];

header('Content-type: image/jpg');
echo $content;

 }
}   

Display.php(動作中)

    $storename = "test123"; // it worked if i store the id in string but not passing from another page.
    $name = (string)$storename;

if(!isset($name) || empty($name)){
     die("Please select your image!");
}else{

$query = mysql_query("SELECT * FROM customerdetail WHERE customer_username='$name'");
$row = mysql_fetch_array($query);
$content = $row['image'];

header('Content-type: image/jpg');
         echo $content;

}
?>  

誰が何がうまくいかないのか理解するのを手伝ってもらえますか? 前もって感謝します。

4

2 に答える 2

0

header('Content-type: image/jpg');コードがから実行されるため、出力がjpg画像になることを宣言します<img src="">

テキストを画像として表示することはできません

于 2013-01-08T11:07:11.723 に答える
0

PHP ファイル (両方) の一番上に、次のコード行を追加します (<?phpもちろん、タグの後に):

session_start();
于 2013-01-08T11:50:35.603 に答える