Sera un Error de sistaxis?
Invalid argument supplied for foreach() in /home/omega75/public_html/include/search.php on line 45
Les dejo el script Aquí.
Código PHP:
<?php
require_once 'SOAP_Google.php';
// Debut de la Configuration
$nr = 10; // Nombre de resultats par page
$clef = 'tu_clave_google'; // Votre clef d'identification sur Google
// Fin de la Configuration
if (strlen($q) > 0) {
$google = new SOAP_Google($clef);
$result = $google->search(
array(
'query' => $q,
'start' => $s,
'maxResults' => $nr,
'restrict' => $country,
'ie' => 'latin1',
'lr' => 'lang_es',
'oe' => 'latin1'
)
);
if (false !== $result) {
echo "<p>Environ {$result['estimatedTotalResultsCount']} documents
trouvés en {$result['searchTime']} secondes.</p>";
echo "<p>Résultats {$result['startIndex']} à {$result['endIndex']}.</p>";
$res = $result['resultElements'];
$i=$result['startIndex'];
//AQUÍ EL ERROR
foreach ($res as $site) {
echo "<p>{$i}. <a href='{$site['URL']}'>{$site['title']}</a><br />
{$site['snippet']}</p>";
$i++;
}
echo "<div align='center'>";
if ($result['startIndex'] >= $nr) {
$t = $result['startIndex'] - ($nr+1);
echo "<p>
<a href='index.php?q=".urlencode($q)."&s=".$t."'><<</a>";
}
echo " Navigation ";
if (($result['estimatedTotalResultsCount'] > $result['endIndex'])
or
!$result['estimateIsExact'] )
{
$t = $result['endIndex'] ;//+ 1;
echo "<a href='index.php?q=".urlencode($q)."&s=".
$t."'>>></a>";
}
echo "</div>";
echo "<hr>";
// print_r($result);
} else {
echo "<p>Probleme dans la requête.</p>";
}
}
?>