为什么在php中会出现此错误?

为什么在php中会出现此错误?,php,Php,我正在使用下面的代码循环访问数据库中的几个链接,以检查每个链接的标题状态 $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("tracker", $con); $result=mysql_query (" SELECT id,ziel_url FROM wm_map

我正在使用下面的代码循环访问数据库中的几个链接,以检查每个链接的标题状态

$con = mysql_connect("localhost","root","");
if (!$con)
{
    die('Could not connect: ' . mysql_error());
}
mysql_select_db("tracker", $con);

$result=mysql_query
        ("

        SELECT id,ziel_url FROM wm_mapping WHERE ziel_url LIKE '%websale7%'");

if (!$result)
{
    echo 'Could not run query: ' . mysql_error();
    exit;
}

$rows=array();
while ($row=mysql_fetch_assoc($result))
{
    $rows[] = $row;
}
$fp = fopen('url.csv', 'a+');
$csv=array();
foreach ($rows as $row){

        file_get_contents($row['ziel_url']);
        $response =$http_response_header[29];
        $csv[] = trim($row['id']).','.trim($row['ziel_url']).','.trim($response);


}
file_put_contents('url.csv', implode("\r\n", $csv), FILE_APPEND);
对于行
$response=$http_response_头[29]我得到一个错误未定义的偏移量:


这是什么意思?

可能是因为
$http\u response\u头
数组中没有30个元素。尝试使用
var\u dump($http\u response\u header)查看数组内容
以查看要使用的元素。

在[]中出错try---foreach($http\u response\u header作为$header){echo$header。“
\n”;}这意味着
$http\u response\u header
变量中没有第29个元素,该变量也没有在任何地方定义。checkout print\r($http\u response\u header);可能你会得到解决方案。请不要使用mysql_*访问数据库,它几乎已弃用,并且包含一些严重的安全漏洞,不适合与mysql 5或更高版本通信。因此$http_response_头不能像我使用的那样使用!!因为它是自动创建的(imho,这是一个可怕的php开发人员的解决方案/实现),并在使用http流(如:file_get_contents('))后插入到当前范围中。。
$response =isset($http_response_header[29])?$http_response_header[29]:SOMETHING_ELSE;