誰でもこのエラーで私を助けることができますか? しばらく様子を見ていましたが、うまくいきませんでした。これは少し前に書いたもので、最後に残したときはうまくいったように感じましたが、再訪したときには実行できませんでした。すべての助けをありがとう。
注意: 46 行目で /Applications/MAMP/htdocs/search/views/layouts/search.php の非オブジェクトのプロパティを取得しようとしています
警告: 46 行目の /Applications/MAMP/htdocs/search/views/layouts/search.php の foreach() に無効な引数が指定されました
46 行目は、コードの最後の行から 4 番目の foreach 行です。
<?php
include($_SERVER['DOCUMENT_ROOT'].'/'.'search/scripts/JSON.php');
include($_SERVER['DOCUMENT_ROOT'].'/'.'search/scripts/search_fns.php');
$searchquery = urlencode(isset($_GET['search']) ? $_GET['search'] : "news");
// Google Search API
$url = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&"
. "q="
. $searchquery
."&key=ABQIAAAAYIeqEnf9yNjBzcHJK7yDdhSklBzi76D_F0lniPI7JR27aK7eCBSU-xpNs1axVS45y_PX_7_ibsScUA&userip=USERS-IP-ADDRESS&rsz=filtered_cse";
// sendRequest
// note how referer is set manually
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_REFERER, "http://localhost");
$body = curl_exec($ch);
curl_close($ch);
// process the JSON string
$json = new Services_JSON;
$json = $json->decode($body);
$formattedresults = "";
$rating = "";
$search = $searchquery;
?>
<style type="text/css">
td img {display: block;}
</style>
<div id="main">
<?php
foreach($json->responseData->results as $searchresult)
{
if($searchresult->GsearchResultClass == 'GwebSearch')
{