Results 1 to 11 of 11
  1. #1
    Join Date
    May 2007
    Posts
    139

    Unanswered: where the error with query[php]

    where the error with query[php]:
    Code:
    $queryAPPEAR2 = "select p.* s.* from $Products p join $Sides s on s.Product_ID = p.Product_ID AND p.Visibility=1 order by s.AA";  
    
    $result2 = @mysql_query($queryAPPEAR2,$linkid);
    $count2 = @mysql_num_rows($result2);
    ....................
    line 214; mysql_free_result($result2);
    // $Sides subset of $Products
    this gives

    Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/content/p/o/l/polisphotos/html/store/admin/sidesFeatured.php on line 214

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by lse123 View Post
    Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource
    that is simply a generic php message that says your mysql query crapped out

    you want to run the query outside of php, so that you can get the actual mysql error message

    (i know what the problem is, but i want to teach you how to find it)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    May 2007
    Posts
    139
    OK, I run in PHPMyAdmin and get error, but not identify yet where, is it the case?
    I can NOT run CLI since shared hosting environment have for hosting...

  4. #4
    Join Date
    May 2007
    Posts
    139
    is it because there are common fields?

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by lse123 View Post
    OK, I run in PHPMyAdmin and get error
    and the error message was ... ?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    May 2007
    Posts
    139
    is it the comma? I modified to [remove join, is it required?]
    select Products.* SidesFeaturedList.* from $Products, $Sides where SidesFeaturedList.Product_ID=Products.Product_ID AND Products.Visibility=1 order by SidesFeaturedList.AA
    get:
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.* from Products, SidesFeaturedList where SidesFeaturedList.Product_ID=Products.' at line 1

  7. #7
    Join Date
    May 2007
    Posts
    139
    was the comma now functions thks

  8. #8
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by lse123 View Post
    was the comma
    yes it was

    now please put back the JOIN
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  9. #9
    Join Date
    May 2007
    Posts
    139
    is it join required...and you say this, I do not think so?
    final now:

    $queryAPPEAR2 = "select Products.*, SidesFeaturedList.* from $Products, $Sides where SidesFeaturedList.Product_ID=Products.Product_ID AND Products.Visibility=1 order by SidesFeaturedList.AA";

  10. #10
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    JOIN syntax is better
    Code:
    SELECT Products.*
         , SidesFeaturedList.* 
      FROM Products
    INNER
      JOIN SidesFeaturedList 
        ON SidesFeaturedList.Product_ID = Products.Product_ID 
     WHERE Products.Visibility = 1 
    ORDER 
        BY SidesFeaturedList.AA
    the missing comma that caused the error was in the SELECT clause

    there should be no commas in the FROM clause

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  11. #11
    Join Date
    Mar 2004
    Posts
    480
    Quote Originally Posted by lse123 View Post
    is it join required...and you say this, I do not think so?
    final now:

    $queryAPPEAR2 = "select Products.*, SidesFeaturedList.* from $Products, $Sides where SidesFeaturedList.Product_ID=Products.Product_ID AND Products.Visibility=1 order by SidesFeaturedList.AA";

    This is still a JOIN, your join is the SidesFeaturedList.Product_ID=Products.Product_ID in the WHERE clause.

Posting Permissions

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