Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Why this Mysql query didn't work? Please help !

    Ok I got many categories, and 1 category i have many products and i have reviews for those products. I got table "products_to_categories " with contains products_id and categories_id. I got another table " reviews " contain products_id and reviews_text, etc... So those 2 table relate by the products_id. Now i want to display those product reviews in that category but It didn't seem to work at all. Note: (int)$current_category_id is the current category, example: 15. I really need this one to work. Thanks alot for any help.
    Below is the code i got:
    Code:
    1)
    <?php
      $categories_to_products = "select products_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where categories_id = '" . (int)$current_category_id . "'";
      $pcategories = tep_db_fetch_array($categories_to_products);
    ?>
    
    2)
    <?php
      $reviews_query_raw = "select r.reviews_id, left(rd.reviews_text, 9000) as reviews_text, r.reviews_rating, r.comfort_rating, r.style_rating, r.date_added, r.customers_name, r.customers_id from " . TABLE_REVIEWS . " r, " . TABLE_REVIEWS_DESCRIPTION . " rd where r.products_id = '" . $pcategories['products_id'] . "' and r.reviews_id = rd.reviews_id and rd.languages_id = '" . (int)$languages_id . "' order by r.reviews_id desc";
      $reviews_split = new splitPageResults($reviews_query_raw, MAX_DISPLAY_NEW_REVIEWS);
    ?>

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,438
    Thanks
    75
    Thanked 4,372 Times in 4,337 Posts
    So what happens when you use that query in a MySQL database *TOOL* instead of in your PHP code???

    How can we guess if your PHP code for splitPageResults is even close to right, for example?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I use it in php and got the message below:
    Code:
    Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, string given in C:\AppServ\www\shoperian\includes\functions\database.php on line 100

  • #4
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I use this splitPageResults in another page and it works perfectly.

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,438
    Thanks
    75
    Thanked 4,372 Times in 4,337 Posts
    Quote Originally Posted by vanvoquan View Post
    I use it in php and got the message below:
    Code:
    Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, string given in C:\AppServ\www\shoperian\includes\functions\database.php on line 100
    Which means you have a PHP error, not a MySQL error. Fix your PHP code.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •