If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > where the error with query[php]

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-11-10, 16:08
lse123 lse123 is offline
Registered User
 
Join Date: May 2007
Posts: 139
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
Reply With Quote
  #2 (permalink)  
Old 11-11-10, 16:42
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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)
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 11-11-10, 16:52
lse123 lse123 is offline
Registered User
 
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...
Reply With Quote
  #4 (permalink)  
Old 11-11-10, 17:06
lse123 lse123 is offline
Registered User
 
Join Date: May 2007
Posts: 139
is it because there are common fields?
Reply With Quote
  #5 (permalink)  
Old 11-11-10, 17:07
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by lse123 View Post
OK, I run in PHPMyAdmin and get error
and the error message was ... ?
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #6 (permalink)  
Old 11-11-10, 17:17
lse123 lse123 is offline
Registered User
 
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
Reply With Quote
  #7 (permalink)  
Old 11-11-10, 17:20
lse123 lse123 is offline
Registered User
 
Join Date: May 2007
Posts: 139
was the comma now functions thks
Reply With Quote
  #8 (permalink)  
Old 11-11-10, 17:36
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Quote:
Originally Posted by lse123 View Post
was the comma
yes it was

now please put back the JOIN
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #9 (permalink)  
Old 11-11-10, 18:09
lse123 lse123 is offline
Registered User
 
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";
Reply With Quote
  #10 (permalink)  
Old 11-11-10, 20:17
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #11 (permalink)  
Old 11-12-10, 09:22
guelphdad guelphdad is offline
Registered User
 
Join Date: Mar 2004
Posts: 440
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On