这个片段导致文件抛出 500 错误,我不明白为什么。
<head>
<?php
$link = mysql_connect('****', '***', '*****');
$db_selected = mysql_select_db('***', $link);
if (!$db_selected) {
echo 'error';
}
$adchan = $_COOKIE['adtail'];
$adarray = json_decode($adchan);
if($adarray->{'subcat'} != 'main'){
$sql = "SELECT term_id FROM wp_terms WHERE slug='$adarray->{'subcat'}'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$id = $row['term_id'];
$sql2 = "SELECT option_value FROM wp_10_options WHERE option_name='$id'";
$result2 = mysql_query($sql2);
while($row2 = mysql_fetch_array($result2))
{
echo "<meta http-equiv='Refresh' content='".$row2['option_value']."'>";
}
}
}
else{
$sql = "SELECT term_id FROM wp_terms WHERE slug='$adarray->{'cat'}'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$id = $row['term_id'];
$sql2 = "SELECT option_value FROM wp_options WHERE option_name='$id'";
$result2 = mysql_query($sql2);
while($row2 = mysql_fetch_array($result2))
{
echo "<meta http-equiv='Refresh' content='".$row2['option_value']."'>";
}
}
}
?>
</head>
谁能明白为什么?
更新
<?php
error_reporting(-1);
$adchan = $_COOKIE['adtail'];
$adarray = json_decode($adchan);
var_dump($adarray);
print $adarray['cat'];
?>
它运行良好,直到打印,也就是我收到 500 错误的时候。输出是:
object(stdClass)#1 (4) { ["cat"]=> string(9) "lifestyle" ["subcat"]=> string(12) "arts-culture" ["page"]=> string(4) "main" ["zone"]=> string(22) "lifestyle/arts-culture" }