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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

condition failing- is it syntax?

Status
Not open for further replies.

NorthStarDA

IS-IT--Management
Joined
Mar 16, 2004
Messages
614
Location
US
i am trying to write a condition and a loop. The condition is always returning false, but I know it shouldn't.
Code:
				while($Row = mysql_fetch_assoc($Result))
				{
					
					if($vm_user_data[county_id] == $Row[county_id])
						print "<option selected value=\"$Row[county_id]\">$Row[county_id]</option>\n";
					else
						print "<option value=\"$Row[county_id]\">$Row[county_id]</option>\n";
				}

now, I know $vm_user_data[county_id] has a value because I printed it later in the page. I am a PHP beginner and I can't tell if I have done this wrong. Appreciate any help.


=========================================
I have not failed. I've just found 10,000 ways that won't work.
Thomas A. Edison
 
actually you need to use quotes (" or '):

if($vm_user_data['county_id'] == $Row['county_id'])

that should do the trick.

jamesp0tter,
jamespotter@netcabo.pt

p.s.: sorry for my (sometimes) bad english :p
 
thanks for the info, i'll add your suggestion but I have just found out it has to do with the value in my county_id variable are title case and the value coming from the Row is all Uppercase. Is there an easy way to make the conditional case-insensative?


=========================================
I have not failed. I've just found 10,000 ways that won't work.
Thomas A. Edison
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top