我爲我的網站構建了一個kindkinda image-api-key,但它似乎不起作用。我得到一個空白頁面,什麼也沒有返回!怎麼了?問候。返回白頁?
if(isset($_GET['key']) && !empty($_GET['key'])){
$query = " SELECT
*
FROM
table
WHERE
apikey = '". mysql_real_escape_string($_GET['key']) ."'
";
$mysqlquery = mysql_query($query);
if($mysqlquery){
if(mysql_num_rows($mysqlquery) > 0){
if(isset($_GET['type']) && isset($_GET['image'])){
if($_GET['type'] == "gif"){
if($_GET['image'] == "1"){
header('Content-type: image/gif');
echo file_get_contents('path/to/image/1.gif');
}
elseif($_GET['image'] == "2"){
header('Content-type: image/gif');
echo file_get_contents('path/to/image/2.gif');
}
elseif($_GET['image'] == "3"){
header('Content-type: image/gif');
echo file_get_contents('path/to/image/3.gif');
}
elseif($_GET['image'] == "4"){
header('Content-type: image/gif');
echo file_get_contents('path/to/image/4.gif');
}
elseif($_GET['image'] == "5"){
header('Content-type: image/gif');
echo file_get_contents('path/to/image/5.gif');
}
else
{
die('Could not load image');
}
}
else
{
die('Could not load image');
}
}
else
{
die('Could not load image');
}
}
else
{
die('Api key was not correct');
}
}
else
{
die('Mysql query failed');
}
}
else
{
die('No api key was set');
}
你確定頭還未被髮送?嘗試在調用`header()`函數之前回顯`intval(headers_sent())`。因爲這可能會導致錯誤,導致空白屏幕。 – Petah 2011-02-06 11:01:24
@Petah它返回'0',所以我認爲它的錯誤... – Thew 2011-02-06 11:06:36