darkfreaks Posted February 16, 2008 Share Posted February 16, 2008 $totalpages = mysql_num_rows($total_results); am idoing something wrong ??? Link to comment https://forums.phpfreaks.com/topic/91434-num_rows-isnt-a-valid-resource/ Share on other sites More sharing options...
pocobueno1388 Posted February 16, 2008 Share Posted February 16, 2008 There is probably something wrong with your query, post more code. Link to comment https://forums.phpfreaks.com/topic/91434-num_rows-isnt-a-valid-resource/#findComment-468468 Share on other sites More sharing options...
darkfreaks Posted February 16, 2008 Author Share Posted February 16, 2008 <?php define('IN_PHPBB', true); $phpbb_root_path = '../architect-jobs-forum/'; include($phpbb_root_path . 'extension.inc'); include($phpbb_root_path . 'common.'.$phpEx); // // Start session management // $userdata = session_pagestart($user_ip, PAGE_INDEX); init_userprefs($userdata); // // End session management // require "../db_conn.inc.php"; $page_title = 'Architect Job Postings'; include ('../includes/header.php'); ?> <table width="100%" border="0" cellspacing="0" cellpadding="2"> <tr> <td align="left" valign="top"><h1><img src="/images/sq_3.gif" width="17" height="17" hspace="5" vspace="5" align="left">Job Postings</h1></td> <td align="right" valign="bottom"><a href="http://www.arkitectum.com/architect-jobs/jobs.php?action=job"><img src="/images/but_post_job.gif" alt="Post an architect job" width="108" height="24" hspace="4" vspace="4" border="0"></a></td> </tr> </table> <table width="100%" border="0" cellspacing="1" cellpadding="2"> <tr> <td align="left"><p><b>Job Seekers:</b> Subscribe to our mailing list and receive daily emails with the latest job postings. </p> <form action="http://www.arkitectum.com/architect-jobs-forum/profile.php?mode=register" method="post"> <p><input type="text" id="email" name="email" value="email address" onfocus="this.value=''" /><input name="Submit" type="submit" value="Subscribe"></p></form></td> <td align="right" valign="bottom"> </td> </tr> </table> <table width="98%" border="0" align="center" cellpadding="4" cellspacing="1" class="forumline"> <tr> <th class="thTop" align="center">Job Title</th> <th align="center">Location</th> <th align="center">Posted</th> </tr> <?php if (isset($_GET['page'])) { $page = $_GET['page']; }else{ $page = 1; } $max_results = 25; $from = (($page * $max_results) - $max_results); if (isset($_POST['Search'])) { $total_results = "SELECT * FROM jobs WHERE NOW() < expires AND paid = '1' "; $total_pages = ceil($total_results / $max_results); $keyword = trim($_POST['keyword']); if($_POST['keyword']!=''){ $find = mysql_real_escape_string(htmlentities($_POST['keyword'])); $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); if(($_POST['category']!='')&&($_POST['location']!='')){ $total_results .= "AND category = '".mysql_real_escape_string($_POST['category'])."' OR location = '".mysql_real_escape_string($_POST['location'])."' OR title LIKE '%$find%' ORDER BY job_id DESC"; $search = TRUE; } elseif(($_POST['category']!='')&&($_POST['location']=='')){ $total_results .= "AND category = '".mysql_real_escape_string($_POST['category'])."' OR title LIKE '%$find%' ORDER BY job_id DESC LIMIT $from,$max_results"; $search = TRUE; } elseif(($_POST['category']=='')&&($_POST['location']!='')){ $total_results .= " AND location = '".mysql_real_escape_string($_POST['location'])."' OR title LIKE '%$find%' ORDER BY job_id DESC LIMIT $from,$max_results"; $search = TRUE; } else { $total_results .= "AND title LIKE '%$find%' ORDER BY job_id DESC LIMIT $from,$max_results"; $search = TRUE; } } else{ if($_POST['location']!=''){// Check if the location isnt empty if($_POST['category']==''){ // Check if category is empty $total_results .= "AND location = '".mysql_real_escape_string($_POST['location'])."' ORDER BY job_id DESC LIMIT $from,$max_results"; $search = TRUE; }// End if category is empty }// End if location isnt empty if($_POST['category']!=''){// Check if the category isnt empty if($_POST['location']==''){ // Check if location is empty $total_results .= "AND category = '".mysql_real_escape_string($_POST['category'])."' ORDER BY job_id DESC LIMIT $from,$max_results"; $search = TRUE; }// End if location is empty }// End if category isnt empty if($_POST['category']!=''){// Check if the category isnt empty if($_POST['location']!=''){ // Check if location is empty $total_results .= "AND category = '".mysql_real_escape_string($_POST['category'])."' AND location = '".mysql_real_escape_string($_POST['location'])."' ORDER BY job_id DESC LIMIT $from,$max_results"; $search = TRUE; }// End Else }// End if location isnt empty }// End if category isnt empty if($search){ $aa = mysql_query($total_results) or die(mysql_error()); $num = mysql_num_rows($row); while($row = mysql_fetch_array($aa)){ extract($row); echo " <tr> <td align='left' valign='top' bgcolor='#F2F5F9'><b><a href='view-job.php?job_id={$row['job_id']}'>". stripslashes($row['title']) ."</a></b> <br>". stripslashes($row['employer']) ."</td> <td align='left' valign='top' bgcolor='#F2F5F9'>{$row['city']}, {$row['location']}</td> <td align='center' valign='top' bgcolor='#F2F5F9' width='70' class='small_10'>". date('M d, y', strtotime($row['date'])) ."</td> </tr>"; if($page > 1){ $prev = ($page - 1); echo " <a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<</a> "; } for($i = 1; $i <= $total_pages; $i++){ if(($page) == $i){ echo "[$i] "; }else{ echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "; } } if($page < $total_pages){ $next = ($page + 1); echo " <a href=\"".$_SERVER['PHP_SELF']."?page=$next\"> >></a> "; } echo'</p>'; }// End While } echo "</table>"; echo"<p align='right'>"; $self=$_SERVER['PHP_SELF']; $nav = ''; }// End if form was submitted include_once ('../includes/footer.htm'); ?> Link to comment https://forums.phpfreaks.com/topic/91434-num_rows-isnt-a-valid-resource/#findComment-468472 Share on other sites More sharing options...
pocobueno1388 Posted February 16, 2008 Share Posted February 16, 2008 I don't see the line of code in your original post anywhere in the code you just posted. Can you just post the relevant part? Link to comment https://forums.phpfreaks.com/topic/91434-num_rows-isnt-a-valid-resource/#findComment-468475 Share on other sites More sharing options...
darkfreaks Posted February 16, 2008 Author Share Posted February 16, 2008 <?php if($search){ $aa = mysql_query($total_results) or die(mysql_error()); $num = mysql_num_rows($row); while($row = mysql_fetch_array($aa)){ extract($row); echo " <tr> <td align='left' valign='top' bgcolor='#F2F5F9'><b><a href='view-job.php?job_id={$row['job_id']}'>". stripslashes($row['title']) ."</a></b> <br>". stripslashes($row['employer']) ."</td> <td align='left' valign='top' bgcolor='#F2F5F9'>{$row['city']}, {$row['location']}</td> <td align='center' valign='top' bgcolor='#F2F5F9' width='70' class='small_10'>". date('M d, y', strtotime($row['date'])) ."</td> </tr>"; if($page > 1){ $prev = ($page - 1); echo " <a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<</a> "; } for($i = 1; $i <= $total_pages; $i++){ if(($page) == $i){ echo "[$i] "; }else{ echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "; } } if($page < $total_pages){ $next = ($page + 1); echo " <a href=\"".$_SERVER['PHP_SELF']."?page=$next\"> >></a> "; } echo'</p>'; ?> Link to comment https://forums.phpfreaks.com/topic/91434-num_rows-isnt-a-valid-resource/#findComment-468478 Share on other sites More sharing options...
pocobueno1388 Posted February 16, 2008 Share Posted February 16, 2008 I still don't see that line of code anywhere. Is it this line giving you the error? $num = mysql_num_rows($row); Where the heck is the $row variable defined? Link to comment https://forums.phpfreaks.com/topic/91434-num_rows-isnt-a-valid-resource/#findComment-468479 Share on other sites More sharing options...
darkfreaks Posted February 16, 2008 Author Share Posted February 16, 2008 row is defined in the fetch array statement after it. and yes it is that line Link to comment https://forums.phpfreaks.com/topic/91434-num_rows-isnt-a-valid-resource/#findComment-468482 Share on other sites More sharing options...
pocobueno1388 Posted February 16, 2008 Share Posted February 16, 2008 Shouldn't it be: $num = mysql_num_rows($aa); $row isn't even a query... Link to comment https://forums.phpfreaks.com/topic/91434-num_rows-isnt-a-valid-resource/#findComment-468484 Share on other sites More sharing options...
darkfreaks Posted February 16, 2008 Author Share Posted February 16, 2008 ok now they pagnation links wont show ??? <?php if($page > 1){ $prev = ($page - 1); echo " <a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<</a> "; } for($i = 1; $i <= $total_pages; $i++){ if(($page) == $i){ echo "[$i] "; }else{ echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "; } } if($page < $total_pages){ $next = ($page + 1); echo " <a href=\"".$_SERVER['PHP_SELF']."?page=$next\"> >></a> "; } echo'</p>'; ?> Link to comment https://forums.phpfreaks.com/topic/91434-num_rows-isnt-a-valid-resource/#findComment-468491 Share on other sites More sharing options...
darkfreaks Posted February 16, 2008 Author Share Posted February 16, 2008 anyone ??? Link to comment https://forums.phpfreaks.com/topic/91434-num_rows-isnt-a-valid-resource/#findComment-468504 Share on other sites More sharing options...
teng84 Posted February 16, 2008 Share Posted February 16, 2008 $page = 1; $total_pages = 15; if($page <= 1){ echo " <a href='#'><<</a> "; } else{ $prev = ($page - 1); echo " <a href=\"".$_SERVER['PHP_SELF']."?page=$prev\"><<</a> "; } for($i = 1; $i <= $total_pages; $i++){ if(($page) == $i){ echo "[$i] "; }else{ echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\">$i</a> "; } } if($page < $total_pages){ $next = ($page + 1); echo " <a href=\"".$_SERVER['PHP_SELF']."?page=$next\"> >></a> "; } ?> gives... << [1] 2 3 4 5 6 7 8 9 10 11 12 13 14 15 >> Link to comment https://forums.phpfreaks.com/topic/91434-num_rows-isnt-a-valid-resource/#findComment-468512 Share on other sites More sharing options...
darkfreaks Posted February 17, 2008 Author Share Posted February 17, 2008 ok according to teng the query is wrong? how would i redo te query so it shows right? Link to comment https://forums.phpfreaks.com/topic/91434-num_rows-isnt-a-valid-resource/#findComment-468548 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.