lucky3809 Posted June 6, 2010 Posted June 6, 2010 I'am coding a new Comment mod, I got it done, however Im trying to add pagination to it, on the viewuser.php and I can't seem to get it to work, what may I be doing wrong? Here is what I got: $limit = 5; $page = abs(@intval($_GET['page'])); $page = isset($page) ? abs(@intval($_GET['page'])):0; $by = 'cTIME'; $order = 'DESC'; $rows = mysql_query("SELECT `ID` FROM `cComments` WHERE (`RecieverID` = ".abs(intval($_GET['u'])).") "); $rows = mysql_num_rows($rows); $pages = ceil($rows/$limit); if($rows % $limit == 0) { $pages; } $pg = 'Pages: '; echo ' <form action="'.$_SERVER['PHP_SELF'].'" method="post"> '.$pg; for($i = 1; $i <= $pages; $i++) { $next = ($i * $limit) - 5; echo '[url="'.$_SERVER['PHP_SELF'].'?page='.$next.'"]'.$i.'[/url]'; } Here are the query to the comment part: $CC = mysql_query("SELECT c.`ID`,c.`cTIME`,c.`SenderID`,c.`RecieverID`,c.`Comment`,u.`userid`,u.`username` FROM `cComments` c LEFT JOIN `users` u "."ON c.`SenderID` = u.`userid` WHERE (`RecieverID` = ".abs(intval($_GET['u'])).") LIMIT ".$page.",".$limit." "); If I add this to the end of the page part RecieverID = {$ir['userid']} ....instead of ....WHERE (`RecieverID` = ".abs(intval($_GET['u'])).") ");... It works, only problem it shows EVERYONES comments I only want it to show that particular user comments, I got the page code from my mail, couldnt get the userlist one to work either. If someone can please help me lol. It's pissing me off I think I may have something wrong with the page count part. Example this is on my viewuser page... trying to add pages I dont want my comments to be limited to show just 5, I want players to scroll through them by clicking pages... Quote
dandre02 Posted June 6, 2010 Posted June 6, 2010 D.w mate i will post a view user later for you ? Quote
lucky3809 Posted June 6, 2010 Author Posted June 6, 2010 D.w mate i will post a view user later for you ? I got a viewuser backup. Ive added a comment mod to it below the sig, and trying to get pagination count on there so players can scroll through all comments instead of just seeing so many. Forgot to mention Ive tried $r['userid'] instead of the $ir and get an error. I know $r is what im needing but it just wont take it, it gives an error in row Quote
Uridium Posted June 6, 2010 Posted June 6, 2010 change $CC = mysql_query("SELECT c.`ID`,c.`cTIME`,c.`SenderID`,c.`RecieverID`,c.`Comment`,u.`userid`,u.`username` FROM `cComments` c LEFT JOIN `users` u "."ON c.`SenderID` = u.`userid` WHERE (`RecieverID` = ".abs(intval($_GET['u'])).") LIMIT ".$page.",".$limit." "); to $CC = $db->query("SELECT c.`ID`,c.`cTIME`,c.`SenderID`,c.`RecieverID`,c.`Comment`,u.`userid`,u.`username` FROM `cComments` c LEFT JOIN `users` u "."ON c.`SenderID` = u.`userid` WHERE (`RecieverID` = ".abs(intval($_GET['u'])).") LIMIT ".$page.",".$limit." "); Quote
lucky3809 Posted June 6, 2010 Author Posted June 6, 2010 I tried that, didnt work, I was able to click the page 1, but it said there was no comments posted, which should have showed the comments that was there. This is what the error is Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/xxxxx/public_html/viewuser.php on line 366 This is line 366: $rows = mysql_query("SELECT `ID` FROM `cComments` WHERE (`RecieverID` = ".abs(intval($_GET['u'])).") "); Quote
Uridium Posted June 6, 2010 Posted June 6, 2010 replace $rows = mysql_query("SELECT `ID` FROM `cComments` WHERE (`RecieverID` = ".abs(intval($_GET['u'])).") "); $rows = mysql_num_rows($rows); $pages = ceil($rows/$limit); if($rows % $limit == 0) with $comment = mysql_query("SELECT `ID` FROM `cComments` WHERE (`RecieverID` = ".abs(intval($_GET['u'])).") "); $rows = mysql_num_rows($comment); $pages = ceil($comment/$limit); if($comment % $limit == 0) Quote
Danny696 Posted June 6, 2010 Posted June 6, 2010 $_SERVER['PHP_SELF'] = insecure replace <form action="'.$_SERVER['PHP_SELF'].'" method="post"> With <form action="" method="post"> Replace <a href="'.$_SERVER['PHP_SELF'].'?page='.$next.'"> With: <a href="?page='.$next.'"> Done Quote
Zero-Affect Posted June 6, 2010 Posted June 6, 2010 $_SERVER['PHP_SELF'] is insecure if you want some info on it check here... $_SERVER['PHP_SELF'] alternative/vulnerability Quote
Djkanna Posted June 6, 2010 Posted June 6, 2010 Wrong section [infobox]Moved to Modification support[/infobox] Quote
lucky3809 Posted June 7, 2010 Author Posted June 7, 2010 Thank you guys about the security help =) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.