Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP Query Problem

Status
Not open for further replies.

ghus32

IS-IT--Management
Jun 4, 2007
20
CA
Hello Everyone,

I am haveing trouble using the results from one query in another query.

$Query= "SELECT email.email, email.id, usermap.id, usermap.email
FROM email
LEFT JOIN usermap ON usermap.email = email.id
WHERE email.email = '$email' ";
$Result = mysql_query( $Query );

$Lookup = "<user_lookup>";
while ( $lookup = mysql_fetch_object( $Result ) )
{
$Lookup .= "<id>".$lookup->id."</id>";

}
$Lookup .= "</user_lookup>";



This query gives me a sigle result and I want to use this result but it is not working..

any suggestions?
 

What is the problem, do you get an error how is it not working?

From what I can gather: your are trying to reference a string that your query is not returning.
Your query is returning either email.id or usermap.id, yet you are asking for id which is rather ambiguous.
Which one do you want?

As a better practice you should not name 2 different variables the same like $Lookup or $lookup. Even though PHP is case sensitive and will now the difference it can lead to confusion later on.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Why mysql_fetch_object and not mysql_fetch_assoc?

Echo the query variable $Query, cut and paste this in MySQL Query and see what happens. If the query only returns one row there isn't much one can do ...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top