I'm not sure at first glance what's wrong. But I do know you could do something like this instead: $query = 'SELECT bio FROM individual '; $query .= "WHERE last_name='$selectedLastname' "; $query .= "AND first_name='$selectedFirstname' "; $query .= "AND market='$selectedMarket' ";
I split it into multiple lines because that's what I like to do, and it helps with clarity and avoids the word-wrapping in e-mail programs. But you should remember the following: 1. Strings can be enclosed in single quotes or double quotes in PHP 2. If you enclose a string in single quotes, you cannot put any special characters or variables within the string (i/e escape characters like \n, $vars, etc). The only thing that gets escaped with a backslash (\) in single-quote strings is single-quotes themselves (so as not to signal the end of the string and confuse the PHP parser). And you can include double quotes within the single quotes just like normal stuff. 3. If you enclose a string in double quotes, you can put any kind of special characters, variables, escaped characters, etc, within it, including single quotes, which get treated just like normal text characters. 4. Single-quote strings get parsed SLIGHTLY (not much) faster than double-quote strings. Just to be anal, I like to use double-quote strings only when I need to. So you can see in my code above, the first line of the query is enclosed in single quotes because it never calls any variables or has any special escaped characters. All the other lines do because they include variables. But they can enclose the variables in single quotes for the SQL query because you can use single quotes within double quotes. Hope this helps. At 09:38 AM 4/22/2002 -0500, R.S. Herhuth wrote: >I have been trying to create strings dynamically by combining text and >variables. Because SQL wants single quotes surrounding the values I >have been forced to create the string as follows (all variables have >been previuosly set earlier on the page): > > >$query = "select bio FROM individual WHERE last_name ='". >$selectedLastname ."' AND first_name ='". $selectedFirstname ."' AND market >='".$selectedMarket."'"; > >Which seems to be good to me but when I echo the query it parses out >like this: > >select bio FROM individual WHERE last_name ='Appleyard >selectedFirstname=Peter selectedMarket=Atlanta' AND first_name ='' AND >market ='' > > >What am I missing...or doing wrong? This seems so straightforward but >I'm getting beat up something horrible! > >Thanks, >Ron Herhuth > >-- >PHP Windows Mailing List (http://www.php.net/) >To unsubscribe, visit: http://www.php.net/unsub.php Mike Flynn - Burlington, VT http://www.mikeflynn.net/ - [EMAIL PROTECTED] home=>work=>home=>store=>home [repeat daily] -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php