2012-06-06 115 views
0

我使用下面的代码回路通过几个从我的数据库链接,来检查的每一个为什么我在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_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_header[29];我我得到一个错误未定义抵消:

这是什么意思?

+0

误差($ http_response_header为$报头) { 回声$头。 “
\ n”; } – swapnesh

+0

这意味着你的'$ http_response_header'变量中没有第29个元素,这个变量在任何地方也没有定义。 – lanzz

+0

yepp您的权利 – lgt

回答

0
$response =isset($http_response_header[29])?$http_response_header[29]:SOMETHING_ELSE; 
+0

因为它是自动创建的(imho它是来自php开发者的一个可怕的解决方案/实现),并在使用http流如file_get_contents('http://site.com/'))之后插入当前范围。 – smassey

0

可能是因为$http_response_header数组中没有30个元素。尝试使用var_dump($http_response_header);查看数组内容以查看要使用的元素。 []内尝试----的foreach

相关问题