[Phpwm] How to get a single string from different queries?

David Goodwin david at codepoets.co.uk
Wed Apr 19 14:54:46 BST 2006


<snip>

> $address = mysql_query("SELECT listingsdbelements_field_value FROM 
> en_listingsdbelements WHERE listingsdbelements_field_name = 'address'") or 

<snip>

> $city = mysql_query("SELECT listingsdbelements_field_value FROM 
> en_listingsdbelements WHERE listingsdbelements_field_name = 'city'") or 


> 
> $full_address=$city.', '.$address;
> 
> 
> The individual queries are returning and echoing the results correctly, but 
> the last string ($full_address) is giving me error (Resource id #3, 
> Resource id #4).
> 

Assuming I understand what you're asking, I don't quite understand your
database structure, but here's an effort at making some sort of reply :)

You're trying to concatenate/join together two query resources. You
can't treat php resource objects as strings.

You probably need to use a different query which is composed of both of 
the above SQL strings, and do mysql_query($sql) on that sql....  so
you'd probably want something a little like :


$full_query = "SELECT listingsdbelements_field_value WHERE
	listingsdbelements_field_name = 'address' or
	listingsdbelements_field_name = 'city'";

$whatever = mysql_query($full_query);

foreach($row as mysql_fetch_row($whatever)) {
 	$row['listingsdbelements_field_name'];
}


(I've not checked this, and i don't use the mysql_ stuff on a day-to-day
basis, so I could easily have typos/invalid functions/rubbish in the
above).


thanks

David.

-- 
David Goodwin 

[ david at codepoets dot co dot uk ]
[ http://www.codepoets.co.uk       ]



More information about the Phpwm mailing list