From: fatblokeonbike [mailto:[EMAIL PROTECTED]

> > > $Query="SELECT properties.area, images.image_filename 
> > > FROM properties, images WHERE 
> > > properties.reference_number=images.reference_number AND
> > > properties.area=$id";
> > >
> > > but it doesn't work - I get the usual "...not a valid MySQL
> > > result resource"
> > > If you can help, thanks in advance.
> >
> >If $id is a string and not an int, then you need to single- or 
> >double-quote it.
> >
> >Try this:
> >
> >$Query="SELECT properties.area, images.image_filename FROM 
> >properties, images WHERE 
> >properties.reference_number=images.reference_number AND
> >properties.area='$id'";
> >
> >HTH!
> Well, not really, I'm afraid - the plain $id takes the visitor 
> to the next page with the correct  POSTed value in the URL.  
> Alas, alas, adding single or double quotes doesn't solve 
> things.
> 
> I've shuffled/altered names around in a (fruitless) attempt 
> to correct things but still, clicking on the hyperlink for 
> "Spain" and echoing the $Query and the $Result to screen I 
> get -
> 
> Query= SELECT properties.caption AS caption, 
> properties.country, properties.area AS area, 
> images.image_filename AS filename FROM properties, images 
> WHERE properties.reference_number=images.reference_number 
> AND properties.country='Spain'
> Result=          i.e. No Result.  Boo-hoo.
> 
> Anything stand out there?


Let's try some debugging on your data, as the query looks fine to me. What about 
running the following queries right in the MySQL console?

SELECT * FROM properties WHERE country='Spain';

That should give you all you need but images.image_filename. If that returns what it 
should, then take reference_number from the results and lookup in images using it:

SELECT image_filename FROM images WHERE reference_number=[reference_number];
(where [reference_number] is from the previous result)

If the first query returns nothing, then your problem is that there's no record for 
properties.country='Spain'. If the second returns nothing, then there's no record for 
images.reference_number matching Spain's reference_number in properties.

Either of those things being off would result in the actual join query returning 
nothing.

Let me know how those turn out...


-- 
Mike Johnson
Web Developer/Systems Asst.
Smarter Living, Inc.
phone (617) 497-2500 x226

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to