lisacowan
asked on
PHP Array Syntax Issue
I have a broken search page here:
http://greenwashingindex.com/search.php?
Depending on what browser you use, you will either see the header of the page and then nothing after it, or you will see nothing at all.
I've tracked the problem down to this line:
$adsList = $ads->GetList(array(array( "adId",">" ,0)));
I think there is something wrong with it but am not sure what Eclipse is not giving me any errors.
I've attached the code of the entire page if that will help .
Any suggestions would be greatly appreciated. I have a very tight deadline on this issue.
Thanks,
Lisa
http://greenwashingindex.com/search.php?
Depending on what browser you use, you will either see the header of the page and then nothing after it, or you will see nothing at all.
I've tracked the problem down to this line:
$adsList = $ads->GetList(array(array(
I think there is something wrong with it but am not sure what Eclipse is not giving me any errors.
I've attached the code of the entire page if that will help .
Any suggestions would be greatly appreciated. I have a very tight deadline on this issue.
Thanks,
Lisa
<?php
$pageClass = "ads";
$pageTitle = "Search Results";
include("header.php");
$ads = new Ad();
$adsList = $ads->GetList(array(array("adId",">",0)));
$top_results = array();
$other_results = array();
$bottom_results = array();
$used_values = array();
?>
<div id="content">
<?php
foreach ($adsList as $theAd) {
$tags_array = explode(",",$theAd->tags);
foreach($tags_array as $theTag) {
$tag = new Tag();
$tag->Get($theTag);
if (strtolower($tag->tagText) == strtolower($_GET['s']) || strtolower($theAd->companyName) == strtolower($_GET['s'])) {
array_push($top_results,$theAd);
array_push($used_values,$theAd->adId);
}//close if
}//close foreach tag
}//close if in tags or company name
foreach ($adsList as $theAd) {
if (strpos(strtolower($theAd->Title), strtolower($_GET['s'])) || strpos(strtolower($theAd->Description), strtolower($_GET['s']))) {
if (!in_array($theAd->adId,$used_values)) {
array_push($other_results,$theAd);
array_push($used_values,$theAd->adId);
}//close if
}//close if in title or description
}//close foreach
$search_terms = explode(" ", $_GET['s']);
foreach ($adsList as $theAd) {
foreach($search_terms as $term) {
if (strpos(strtolower($theAd->Title), strtolower($term)) || strpos(strtolower($theAd->Description), strtolower($term))) {
if (!in_array($theAd->adId,$used_values)) {
array_push($bottom_results,$theAd);
array_push($used_values,$theAd->adId);
}//close if
}//close if in title or description
}//close foreach search term
}//close foreach
$all_results = array_merge($top_results,$other_results);
?>
<?php
if (count($all_results) > 0 && count($bottom_results) > 0) {
?>
<h3>Top Results for <?php echo $_GET['s'] . " (" . count($all_results); ?>)</h3>
<?php
}//close if
elseif (count($all_results) > 0) {
?>
<h3>Search Results for <?php echo $_GET['s'] . " (" . count($all_results); ?>)</h3>
<?php
}
foreach ($all_results as $theAd) {
$ratings = new Rating();
$ratingsList = $ratings->GetList(array(array("AdId","=",$theAd->adId)));
$submitter = new User();
$submitter->Get($theAd->PostedBy);
?>
<dl>
<dt><a href="ad_single.php?id=<?php echo $theAd->adId; ?>" title="<?php echo $theAd->Title; ?>"><?php echo $theAd->Title; ?></a></dt>
<dd class="image"><a href="ad_single.php?id=<?php echo $theAd->adId; ?>" title="<?php echo $theAd->Title; ?>">
<?php
if ($theAd->Type == "0") {
embed_video_thumbnail($theAd->URL);
}//close if video
if ($theAd->Type == "1") {
embed_image_thumbnail($theAd->URL, $theAd->Title);
}//close if image
?>
</a></dd>
<dd class="date"><?php echo date("F j, Y", strtotime($theAd->PostedDate)); ?></dd>
<dd class="user">Submitted by <span><?php echo $submitter->Username; ?></span></dd>
<dd>Greenwashing Index Rating: <span><?php if ($theAd->AvgRating != 0) { echo round($theAd->AvgRating,2); } else {echo "Not yet rated"; } ?></span></dd>
<?php if ($theAd->AvgRating != 0) {?>
<dd><a href="ad_single.php?id=<?php echo $theAd->adId; ?>#ratings" title="Number of ratings"><?php echo count($ratingsList) + 1; ?> rating<?php if (count($ratingsList) != 0) {?>s<?php }?></a></dd>
<?php } ?>
</dl>
<?php
}//close for each ad
if (count($bottom_results) > 0) {
if (count($all_results) <= 0) {
?>
<h3>Search Results for <?php echo $_GET['s'] . " (" . count($bottom_results); ?>)</h3>
<?php
}//close if
else {
?>
<h3><a href="#" title="Show All Results" id="show_all_results">Show All Results (<?php echo count($bottom_results); ?>)</a></h3>
<?php
}//close else
?>
<div id="more_results" <?php if (count($all_results) > 0) { echo "class='initial_hide'"; } ?>>
<?php
foreach ($bottom_results as $theAd) {
$ratings = new Rating();
$ratingsList = $ratings->GetList(array(array("AdId","=",$theAd->adId)));
$submitter = new User();
$submitter->Get($theAd->PostedBy);
?>
<dl>
<dt><a href="ad_single.php?id=<?php echo $theAd->adId; ?>" title="<?php echo $theAd->Title; ?>"><?php echo $theAd->Title; ?></a></dt>
<dd class="image"><a href="ad_single.php?id=<?php echo $theAd->adId; ?>" title="<?php echo $theAd->Title; ?>">
<?php
if ($theAd->Type == "0") {
embed_video_thumbnail($theAd->URL);
}//close if video
if ($theAd->Type == "1") {
embed_image_thumbnail($theAd->URL, $theAd->Title);
}//close if image
?>
</a></dd>
<dd class="date"><?php echo date("F j, Y", strtotime($theAd->PostedDate)); ?></dd>
<dd class="user">Submitted by <span><?php echo $submitter->Username; ?></span></dd>
<!--<dd><?php echo $theAd->Description; ?></dd>-->
<dd>Greenwashing Index Rating: <span><?php if ($theAd->AvgRating != 0) { echo round($theAd->AvgRating,2); } else {echo "Not yet rated"; } ?></span></dd>
<?php if ($theAd->AvgRating != 0) {?>
<dd><a href="ad_single.php?id=<?php echo $theAd->adId; ?>#ratings" title="Number of ratings"><?php echo count($ratingsList) + 1; ?> rating<?php if (count($ratingsList) != 0) {?>s<?php }?></a></dd>
<?php } ?>
</dl>
<?php
}//close for each ad
?>
</div><!--close #more_results-->
<?php
}//close if more results
if (count($all_results) <= 0 && count($bottom_results) <= 0) {
?>
<h3>No search results</h3>
<?php
}//close if
?>
</div><!--close content-->
<?php include("sidebar.php"); ?>
<?php include("footer.php"); ?>
ASKER
Test comment.
ASKER
Hmm. Something odd just happened there.
Anyway, thanks for the speedy answer.
The page ends at line 76 when the offending line of PHP is in the file. If I removed it, the entire page renders, but I get no search results. I've attached what the HTML looks like. It doesn't validate perfectly, but there is nothing in there that should keep the page from working.
Thanks,
Lisa
Anyway, thanks for the speedy answer.
The page ends at line 76 when the offending line of PHP is in the file. If I removed it, the entire page renders, but I get no search results. I've attached what the HTML looks like. It doesn't validate perfectly, but there is nothing in there that should keep the page from working.
Thanks,
Lisa
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>The EnviroMedia Greenwashing Index – Search Results</title>
<!--Daniel's Scripts-->
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.rotator.js"></script>
<script type="text/javascript" src="js/interface.js"></script>
<script type="text/javascript" src="js/jquery.form.js"></script>
<script type="text/javascript" src="js/jquery.cluetip.js"></script>
<script type="text/javascript" src="js/jquery.dimensions.js"></script>
<script type="text/javascript" src="js/all.js"></script>
<!--swfobject to embed Flash-->
<script type="text/javascript" src="js/swfobject.js"></script>
<link rel="stylesheet" type="text/css" href="styles/screen.css" media="screen" />
<link rel="stylesheet" type="text/css" href="js/jquery.cluetip.css" media="screen" />
<!--[if IE]><link rel="stylesheet" type="text/css" href="styles/slider_ie.css" media="screen" /><![endif]-->
<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="styles/ie6.css" media="screen" /><![endif]-->
<!--[if lt IE 8]><link rel="stylesheet" type="text/css" href="styles/ie7.css" media="screen" /><![endif]-->
</head>
<body class="ads">
<div id="wrapper">
<div id="header">
<h1 id="home"><a href="index.php" title="EnviroMedia Greenwashing Index, return home" class="home">EnviroMedia Greenwashing Index</a><br />
<a href="http://www.enviromedia.com" title="EnviroMedia's website" class="esm">Promoted by EnviroMedia Social Marketing</a> <a href="http://www.uoregon.edu/" class="uo">and the University of Oregon</a></h1>
<!-- UTILITY NAV IF USER IS SIGNED IN -->
<div id="util_nav_yes">
<ul>
<li class="lefty" id="welcome_message">Welcome, lcowan</li><br />
<li class="lefty"><a href="index.php?action=signout" title="Sign Out">Sign Out</a></li>
</ul>
</div>
</div>
<div id="google_search">
<form action="search.php">
<input type="text" name="s" class="search_input" />
<input type="image" src="images/btn_search.gif" class="image_submit image_submit_search" />
</form>
<script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en"></script>
</div>
<ul id="global_nav">
<li id="submit"><a href="submit.php" title="Post an Ad">Post an Ad</a></li>
<li id="ads"><a href="ads.php" title="View the Ads">View/Rate Ads</a></li>
<li id="about"><a href="what.php" title="About Greenwashing">About Greenwashing</a></li>
<li id="news"><a href="news.php" title="In the News">In the News</a></li>
<li id="commentary"><a href="commentary.php" title="Commentary">Commentary</a></li>
</ul>
<div id="content_wrap">
<div id="content">
<h3>No search results</h3>
</div><!--close content-->
<div id="sidebar">
<div class="rating_scale"> <a href="criteria.php"><img src="images/rating_scale2.png" alt="Greenwashing Index Rating Scale - 1 is a good ad, 3 is the midpoint and the ad is pushing it, 5 is total greenwashing" /></a><br />
</div>
<div class="about_sub">
<h3>About Greenwashing</h3>
<ul class="sidebar">
<li id="what"><a href="what.php" title="What is Greenwashing?">What is Greenwashing?</a></li>
<li id="spot"><a href="spot_gw.php" title="How Do I Spot It?">How Do I Spot It?</a></li>
<li id="why"><a href="why.php" title="Why is Greenwashing a Problem?">Why is Greenwashing a Problem?</a></li>
<li id="criteria"><a href="criteria.php" title="Greenwashing Index Scoring Criteria">GWI Scoring Criteria</a></li>
<li id="purpose"><a href="purpose.php" title="Purpose of the Greenwashing Index">Purpose of the GWI</a></li>
</ul>
</div>
<h3>Get Involved</h3>
<p class="sidebar"><a href="contact.php" title="Sign up on the mailing list">Sign up on our mailing list</a> to stay up-to-date with the Greenwashing Index.</p>
<h3>Useful Links</h3>
<ul>
<!--<li><a href="http://www.google.com/translate_t" title="Google Translate">Translate this page</a></li>-->
<li><a href="http://www.enviromedia.com/enviroblog" title="Climate Change Starts Here blog">“Change Starts Here” blog</a></li>
<li>University of Oregon School of Journalism and Communications: <br />
<a href="http://jcomm.uoregon.edu/faculty-staff/debmor" title="Dr. Deborah Morrison">Dr. Deborah Morrison, Ph.D.</a><br />
<a href="http://jcomm.uoregon.edu/faculty-staff/ksheehan" title="Dr. Kim Sheehan">Dr. Kim Sheehan, Ph.D.</a></li>
<li class="img"><a href="http://www.enviromedia.com" title="EnviroMedia web site"><img src="images/emi_logo.gif" alt="EnviroMedia Social Marketing logo" /></a></li>
</ul>
</div>
<div id="clearfooter"></div>
</div>
</div>
<div id="footer">
<ul class="footer_nav">
<li><a href="rss.php">RSS</a></li>
<li><a href="contact.php">Contact</a></li>
<li><a href="terms.php">Terms of Use</a></li>
</ul>
<p>© 2010 EnviroMedia Social Marketing<br />
Greenwashing Index is promoted by EnviroMedia Social Marketing in partnership with the University of Oregon School of Journalism and Communication<br />
<span>The ads posted and evaluated here are not submitted or rated by EnviroMedia Social Marketing staff and the opinions, views and statements found on this site do not necessarily reflect those of EnviroMedia Social Marketing, its principals or employees.</span></p>
</div>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-2902130-3";
urchinTracker();
</script>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'll check this in the morning.
ASKER
It turned out to be a memory error in PHP. We increased the memory allocation, and that did the trick. Thank you so much for your suggestions.
Lisa
Lisa
Glad you're sorted.
ASKER
I'm accepting this as the answer because turning on the error reporting helped me find the memory issue.
Thanks for the help.
Lisa
Thanks for the help.
Lisa
http://validator.w3.org/check?uri=http%3A%2F%2Fgreenwashingindex.com%2Fsearch.php%3F&charset=%28detect+automatically%29&doctype=Inline&ss=1&group=0&verbose=1&user-agent=W3C_Validator%2F1.1
I cannot find the last DIV <div id="content_wrap"> in your source or the one that precedes it so is there other source that you have not included?