Guest User

Untitled

a guest
Jul 20th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. Fatal error: Call to a member function fetch_assoc() on a non-object in D:xampphtdocsSuperfacil_v1.2.8.9incclass_search.php on line 32
  2.  
  3. $smtp_category_cc = "SELECT count(*) as total FROM public_ads WHERE $construct";
  4. $smtp_category_qry_cc = $con->query($smtp_category_cc);
  5. $total_request = $smtp_category_qry_cc->fetch_assoc();
  6.  
  7. $name = mysqli_real_escape_string($con, sanitize($_GET['search']));
  8. $category = mysqli_real_escape_string($con, sanitize($_GET['category']));
  9. $x = 0;
  10. $q = str_replace(array("\",";"), "", $name); // remove ALL backslashes & remove ALL ";" -> for sql security: no (simple) injection of commands
  11. $q = trim($q);
  12. $search_exploded = explode(" ", $q);
  13.  
  14. foreach($search_exploded as $search_each ) {
  15.  
  16. $x++;
  17. $construct = " ";
  18.  
  19. if($x == 1) {
  20. $construct .= "ads_title LIKE '%$search_each%' AND category_id = '$category' AND ads_active = 1 AND ads_end = 0";
  21. } else {
  22. $construct .= "AND ads_brand LIKE '%$search_each%' AND category_id = '$category' AND ads_active = 1 AND ads_end = 0";
  23. }
  24. }
  25.  
  26. /**************************/
  27. $smtp_category_cc = "SELECT count(*) as total FROM public_ads WHERE $construct";
  28. $smtp_category_qry_cc = $con->query($smtp_category_cc);
  29. $total_request = $smtp_category_qry_cc->fetch_assoc();
  30.  
  31. echo '<p class="shop-results">Encontrados <span class="badge">'. $total_request['total'] .'</span> <strong>An&uacute;ncios</strong>. </p>';
  32. /**************************/
  33.  
  34.  
  35. $get_search = "SELECT ads_id, client_id, category_id, ads_title, ads_brand, ads_content, ads_price, ads_views, ads_image_1, ads_image_2, ads_image_3, ads_date FROM public_ads WHERE $construct";
  36. $get_search_qry = $con->query($get_search);
  37.  
  38.  
  39. if($get_search_qry->num_rows > 0) {
Add Comment
Please, Sign In to add comment