Thank you so far for the response, I think maybe I needed to post more code for you to see what's going on here. I think the problem is in the query statement or my limits. Here's the full code:
Code: Select all
<?php
include('header.php');
/* Let's submit something */
if($_POST['submit']){
if(!isset($_SESSION['user']['username'])) $username = "Anonymous";
else $username = $_SESSION['user']['username'];
@$query = mysql_query("INSERT INTO `comps`(time,message,accepted,votes1,votes2,via,user,cat,numcoms,subcat) VALUES ('". time() ."', '". clean($_POST['comp']) ."', 'No', 0, 0, 'internet', '". $username ."', '". clean($_POST['cat']) ."', '0', '0')") or die(mysql_error());
echo "<strong>Your submission has been received!</strong>
<script type=\"text/javascript\"><!--
setTimeout('Redirect()',1000);
function Redirect()
{
opener.location.href='./';
window.close();
}
// --></script>";
} else {
}
$cnt = '<p style="font-size: 18px; font-weight: bold;">Share your terrible or awesome predicament.</p>
<p> Concept: Your submission should always end with <b>"NHNL?"</b> (meaning "New high or new low?") </p> <p>Please avoid using texting language and read your post over before submitting.</p>
Thanks for participating! </p></br></br><form action="submitCompliment.php" class="submit_form" method="POST" target="sendCommentIFrame">
<table id="submissionform">
<tr><td class="input" colspan=5>
<textarea onfocus="javascript:document.getElementById(\'commbox\').value=\'\';" name="comp" rows="13" height="75" cols="20" id="commbox">'. $names[4] .'</textarea>
</td></tr>
<tr><td><p>Want your own Name? <span style="color : #028013"><a href="http://www.newhighnewlow.com/register.php">Getting one</a></span> takes 2 seconds.</p>
<select name="cat">';
while($category = current($catlist)){
$cnt .= '<option value="'. key($catlist) .'">'. current($catlist) .'</option>';
next($catlist);
}
$cnt .= '
</select></td></tr> <tr><td><input type="submit" name="Ok" value="Submit!" class="button_login2"/>
</td></tr>
<tr><td>
<div id="loadingsubmit_article" style="display:none;"><img src="images/loader.gif"/></div>
<div id="resultsubmit_article" style="display:none;"></div>
</td></tr>
</table>
</form><iframe name="sendCommentIFrame" style="display:none"></iframe>';
$maincontent = "<h1><a href=\"javascript:submitToggle();\" class=\"submit\" style=\"font-weight: bold;\">" . $submitpop . "</a></h1><div style=\"display: none;\" id=\"submit\" class=\"post\"><div id=\"result2\" class=\"result\">" . $cnt . "</div></div>";
/* To institute TOP BANNER ADS: Place this code--> <style=\"margin-left:40px;\"><script type=\"text/javascript\"><!--
google_ad_client = \"pub-2934960017790058\";
google_ad_slot = \"2975484663\";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type=\"text/javascript\"
src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">
</script></style>
<--End of code
Between the > and the " at the end of the previous line. Repeat for each category page and Random page*/
/* submissions done! Let's move on to displaying our content */
$maincontent .= "<div id=\"mainresultlist\">\n";
$comp = $_GET['comp'];
if(!isset($comp)){
if(!$page) $page = 1;
$npage = $page - 1;
if($c){
$addsql = " AND `cat` = '". $c ."'";
$addhtml = "&c=". $c;
}
$limit1 = $npage * 10;
$limit2 = $npage + 10;
$q = "SELECT * FROM `comps` WHERE `accepted` = 'Yes'". $addsql ." ORDER BY `time` DESC LIMIT ". $limit1 .", ". $limit2;
print $q;
$r = mysql_query($q);
$voting_array = mysql_fetch_array(mysql_query("SELECT * FROM `votes` WHERE `ip`='$ip'"));
$vote_explode = explode(',', $voting_array['comp_id']);
foreach($vote_explode as $vote_ex){
$vote_ex = explode(":", $vote_ex);
$compnum = $vote_ex[0];
$compvote = $vote_ex[1];
$compvotearray[$compnum] = $compvote;
}
if(mysql_num_rows($r) > 0){
while($row = mysql_fetch_array($r, MYSQL_ASSOC)){
// count the comments
$commentsCountQuery = "select * from comments where comp_id=" . $row['id'];
$commentsCountResult = mysql_query($commentsCountQuery);
$commentsCount = mysql_num_rows($commentsCountResult);
$maincontent .= "<br />\n<div id=\"result". $row['id'] ."\" class=\"result\">\n";
$maincontent .= stripslashes($row['message']) ."\n<br /><br />\n";
$maincontent .= '<span class="sentBy"><span class="lside"><a href="comment-'. $row['id'] .'" class="commlink">read comments ('. $commentsCount .')</a></span>';
if(!$compvotearray[$row['id']]){
$maincontent .= '<span id="vote_buttons'. $row['id'] .'" class="vote_buttons">
<span id="a1votes_count'. $row['id'] .'">
<a id=":'. $row['id'] .':1:'. $row['votes1'] .':'. $row['votes2'] .':" class="vote_up" title="'. $phrase1 .':'. $phrase2 .'" href="javascript:;">
'. $phrase1 .' ('. $row['votes1'] .')</a></span>';
$maincontent .= ' - <span id="a2votes_count'. $row['id'] .'">
<a id=":'. $row['id'] .':2:'. $row['votes1'] .':'. $row['votes2'] .':" class="vote_down" title="'. $phrase1 .':'. $phrase2 .'" href="javascript:;">
'. $phrase2 .' ('. $row['votes2'] .')</a>
</span></span><br />';
} else {
$maincontent .= '<span id="vote_buttons'. $row['id'] .'" class="vote_buttons voted">
<span id="a1votes_count'. $row['id'] .'">
'. $phrase1 .' ('. $row['votes1'] .')</span>';
$maincontent .= ' - <span id="a2votes_count'. $row['id'] .'" class="vote_buttons voted">
'. $phrase2 .' ('. $row['votes2'] .')
</span></span><br />';
}
$maincontent .= '<span class="mesdetail">'. date('F j, Y \a\t g:i a ', $row['time']) .'by <a href="' . $row['user'] . '_' . $row['user'] .'-'. $row['user'] . '">'. $row['user'] .'</a>
</span>';
$maincontent .= '<span class="mesdetail"> in - <a href="category-'. $row['cat'] .'_'. $catlist[$row['cat']] .'">'. $catlist[$row['cat']] .'</a></span>';
$maincontent .= "</span>";
if($sharelinks == 'yes') $maincontent .= '<span id="addslider'. $row['id'] .'">
<a class="addslide" onclick="Slide(\'result'. $row['id'] .'\',\'down\');" href="javascript:;" style="">[+]</a>
</span>
<div id="sharelinks'. $row['id'] .'" class="sharelinks">'. $sharelinkscode .'</div>';
$maincontent .= "</div>";
}
} else {
$maincontent .= "<strong>There are no results in this category.</strong>";
}
$q = "SELECT COUNT(*) FROM `comps` WHERE `accepted` = 'Yes'". $addsql;
$r = mysql_query($q);
$num = mysql_fetch_array($r);
$nbrPages = ceil($num[0] / 10);
$i = 1;
$maincontent .= "<br />";
// Pagination links.
$nbrPages = $nbrPages;
$thisPage = "";
include("pagination.php");
$maincontent .= $paginationLinks;
// while($i <= $nbrPages){
// if($i == 1) $maincontent .= "Pages: ";
// if($i != $page) $maincontent .= "<a href=\"?page=". $i . $addhtml ."\">". $i ."</a>\n ";
// else $maincontent .= $i ." ";
// $i++;
// }
} elseif ($comp){
include('comment.php');
}
$maincontent .= "\n</div>";
$layout = str_replace("[[main-content]]", $maincontent, $layout);
echo $layout;
?>
JAB Creations: I did change as suggested. No change in behavior, but maybe with more code it will be easier to see my error.
susrisha: I did print, and I get the same result: SELECT * FROM `comps` WHERE `accepted` = 'Yes' ORDER BY `time` DESC LIMIT 0, 10 from any page. I'm just not sure where I'm failing here.
Thanks again for the responses and your continued help.