Antisocial Posted March 7, 2008 Share Posted March 7, 2008 Hi, I'm fairly new to PHP/MySQL and need some help. I'm trying to make a search page with all the functionality of my results page... Various results are passed: page, orderby, limit Others gathered from post: search, limit (change) I keep getting the same error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/httpd/vhosts/imomedia.net/httpdocs/jobsheet/search.php on line 95 So I'm guessing its my SELECT statement... All the $values look like they return what they're supposed to... Please help! // snip // [pre]if(isset($_GET['orderby'])) { $orderby=$_GET['orderby']; }else{ $orderby = "jsid"; } if(isset($_POST['category'])) { $cat=$_POST['category']; }else{ $cat = "works"; } if(isset($_POST['gosearch'])) { $search=$_POST['search']; }else{ echo "Nothing to search for, please try again"; } $pageNum = 1; // Get number of results per page if(isset($_POST['filter'])) { $limit=$_POST['flimit']; }else{ if(isset($_GET['limit'])) { $limit=$_GET['limit']; }else{$limit = 20; } } // if $_GET['page'] defined, use it as page number if(isset($_GET['page'])) { $pageNum = $_GET['page']; }else{ $pageNum == 1; } // counting the offset $offset = ($pageNum - 1) * $limit; $query = "SELECT * FROM jobsheet WHERE $cat LIKE %$search% ORDER BY $orderby LIMIT $offset,$limit"; $result = mysql_query($query); $num = mysql_num_rows($result);[/pre] // snip // Quote Link to comment Share on other sites More sharing options...
Antisocial Posted March 7, 2008 Author Share Posted March 7, 2008 I left the ' ' s off the like statement, please ignore/delete. Thanks Quote Link to comment Share on other sites More sharing options...
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.