Try to change this:

curl_setopt($ch,CURLOPT_URL,$targets);

to:

curl_setopt($ch,CURLOPT_URL, $target_url);

Zechim
zechim.com
São Paulo/Brazil


-----Mensagem original-----
De: Miller, Terion [mailto:tmil...@springfi.gannett.com] 
Enviada em: sexta-feira, 8 de maio de 2009 09:50
Para: PHP-General List
Assunto: [PHP] CURL error help

Trying to run a script on several different pages within the same site by
making the url's an array...anyone see a better way to do this?

Trying to resolve some curl errors and need some help, here are the errors:


Notice: Array to string conversion in
/var/www/vhosts/getpublished.news-leader.com/httpdocs/Warrants/loopScrape1.p
hp on line 34

Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot
be activated when in safe_mode or an open_basedir is set in
/var/www/vhosts/getpublished.news-leader.com/httpdocs/Warrants/loopScrape1.p
hp on line 36

cURL error number:6
cURL error:Couldn't resolve host 'Array'

And here is the code:
<?php

ini_set('display_errors',
1);
include("inc/dbconn_open.php");

include("inc/dom.php");

error_reportin
g(E_ALL);

$TESTING = TRUE;


 $targets["a"] =
"http://www.greenecountymo.org/sheriff/warrants.php?search=A";;

$targets["b"] = 
"http://www.greenecountymo.org/sheriff/warrants.php?search=B";;

$targets["c"] = 
"http://www.greenecountymo.org/sheriff/warrants.php?search=C";;

$targets["d"] = 
"http://www.greenecountymo.org/sheriff/warrants.php?search=D";;

$targets["e"] = 
"http://www.greenecountymo.org/sheriff/warrants.php?search=E";;

$targets["f"] = 
"http://www.greenecountymo.org/sheriff/warrants.php?search=F";;

$targets["g"] = 
"http://www.greenecountymo.org/sheriff/warrants.php?search=G";;

$targets["h"] = 
"http://www.greenecountymo.org/sheriff/warrants.php?search=H";;

$targets["i"] = 
"http://www.greenecountymo.org/sheriff/warrants.php?search=I";;

$targets["j"] = 
"http://www.greenecountymo.org/sheriff/warrants.php?search=J";;

$targets["k"] = 
"http://www.greenecountymo.org/sheriff/warrants.php?search=K";;

$targets["l"] = 
"http://www.greenecountymo.org/sheriff/warrants.php?search=L";;
 
 
 foreach
($targets as $target_url){

$userAgent = 'Googlebot/2.1
(http://www.googlebot.com/bot.html)';


$ch = curl_init();
curl_setopt($ch,
CURLOPT_USERAGENT, $userAgent);
curl_setopt($ch,
CURLOPT_URL,$targets);
curl_setopt($ch, CURLOPT_FAILONERROR,
true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch,
CURLOPT_AUTOREFERER, true);
curl_setopt($ch,
CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_TIMEOUT, 300);
$html
= curl_exec($ch);
if (!$html) {
    echo "<br />cURL error number:"
.curl_errno($ch);
    echo "<br />cURL error:" . curl_error($ch);

exit;
}


// Create DOM from URL or file
$html =
file_get_html('$target_url');

// Find table
foreach($html->find('table') as
$table)
{
    foreach($table->find('tr') as $tr)
    {


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to