Current location: Hot Scripts Forums » Programming Languages » PHP » sub query / nested select error in php4


sub query / nested select error in php4

Reply
  #1 (permalink)  
Old 01-13-09, 05:28 PM
APuppyDog APuppyDog is offline
Newbie Coder
 
Join Date: Jul 2003
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
sub query / nested select error in php4

I have a page that works fine in php5 but the same code does not work in php4. Due to the circumstances, i have to make it work in php4 for the time being... can you gurus suggest how I can resolve this to work with php4?

PHP Code:

$sql="select distinct car_auctions.leading_bidder from car_auctions where car_auctions.auction_closed=1 and car_auctions.buyer_fees>0 and car_auctions.buyer_fees_charged_status<>1 and car_auctions.leading_bidder in (SELECT user_master.user_name from user_details,user_master where user_master.user_id=user_details.user_id and user_details.user_status=2)";


$rec=mysql_query($sql);  
$rs=mysql_fetch_array($rec); 
i get the following error
Quote:
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 'SELECT user_master.user_name from user_details,user_master wher
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 01-14-09, 12:24 AM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
First see if you can rename the file to .php5. Many hosting companies install both PHP4 & PHP5 - and let you get to PHP5 using .php5. If that's not an option ....

It looks like it might be an SQL error, or an SQL error related to the PHP version - with the (SELECT ...) causing a problem. Try breaking the SQL into two statements or rewriting it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 01-14-09, 12:33 AM
APuppyDog APuppyDog is offline
Newbie Coder
 
Join Date: Jul 2003
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
hi wirehopper, thanks for your feedback. I tried .php5 (hosted with godaddy) and even though they have php5 installed, it didn't seem to work for me.

as for rewriting it.. i found a solution online but not sure how to apply it to my code..

here is what i found:

the code was
Code:
SELECT books.idbook, books.title 
FROM books
WHERE EXISTS (SELECT * FROM out_of_stock WHERE out_of_stock.city =  'london' 
AND out_of_stock.idbook = books.idbook)
Code:
SELECT books.idbook, books.title
FROM books LEFT OUTER JOIN out_of_stock
ON out_of_stock.city = 'london'
AND books.idbook = out_of_stock.idbook
WHERE out_of_stock.idbook IS NULL;
now i need to know how to get
Code:
SELECT distinct car_auctions.leading_bidder 
FROM car_auctions 
WHERE car_auctions.auction_closed=1 
AND car_auctions.buyer_fees>0 
AND car_auctions.buyer_fees_charged_status<>1 
AND car_auctions.leading_bidder 
 in (SELECT user_master.user_name 
      FROM user_details,user_master 
      WHERE user_master.user_id=user_details.user_id 
      AND user_details.user_status=2)
to the way they wrote it in the second set of codes..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
code problem throws error matt001 ASP.NET 0 10-23-05 04:30 AM
Nested Query in PHP/MYSQL truesilentassassin PHP 2 07-27-04 08:50 PM
MySQL SELECT query result dividing ICE Flame PHP 1 06-06-04 03:50 PM
Declared Functions skipper23 PHP 4 12-17-03 11:06 AM
index page not showing up skipper23 PHP 3 12-15-03 02:10 PM


All times are GMT -5. The time now is 07:52 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.