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

HTML code accessing SQL Data

Status
Not open for further replies.

lewis33

Technical User
May 21, 2001
64
US
Got an odd problem that is probably more of an HTML isssue. Got some queries that search via two drop down lists. Everything is working correctly except for two of the values in the drop down lists. After stareing at this for a while, I think I may have isolated the problem. In one of the drop down lists, I have a product "Diet Plus" that relates to a product code of "DP+". When the user selects that one.......it produces no results from the SQL Server data though I know the query is correct per the data.

Then, in the specialty drop down list, I have a few entries with that produce &quot;The page cannot be displayed&quot; errors. I noticed that all of these entries have the '&' in them like <option value=&quot;Vets & others</option> in the HTML source code someone wrote for me.

Any ideas on this topic (I know cliched) but appreciated for the rest of my breathing days. Thanks from Cleveland.
 
the html code

<option value=&quot;Vets & others</option>

will not work because it's missing a quote

you should really use primary keys for searching, so that, for example, your dropdown list code looks like this --

<select name=&quot;products&quot;>
<option value=&quot;1&quot;>widgets</option>
<option value=&quot;2&quot;>gizmos</option>
<option value=&quot;3&quot;>doohickies</option>
</select>

thus, your search code will use key values like 2 rather than descriptions like &quot;Vets & others&quot;


rudy
 
Rudy, you're right, the primary key (or I guess, even a numberic indicator) would be preferred. Acutally, I typed that in wrong- I do have the correct quotes in there but it still does not search - or it produces errors- for any product or specialty that has an '+' or an '&'.

In the source code, the entry is:

<td width=&quot;375&quot;><p class=&quot;content&quot;>Provider Specialty</p></td>
<td width=&quot;375&quot;><select name=&quot;spec&quot; size=&quot;1&quot;>
<option value=&quot;&quot; selected> -- Provider Specialty -- </option>
><option value=&quot;VETS & others&quot;>Vets & Others</option>

Thanks for your input Rudy.
 
dunno

might not be an SQL problem at all

i'd have to see your actual query

or, try the ASP forum, if that's what you're using


rudy
 
If you are using ASP its should be easy to find what sql statement is passed to SQL Server. Some where in your code you have a variable say varSQL=&quot; your sql statement here&quot;
Then you pass this variable as a parameter to the Execute method of your connection object or to the open method of the recordset. To see the Query passed to sql server
Type this Response.write varSQL and on the next line type Response.Flush
just before passing the varSQL to the methods above mentioned. Your query should appear on the page and you can look at it closely or you can even copy it and paste it in the query analyzer and try to execute it from there. You shoud be able to pick up syntax errors quite easily.
Regards;
Black belt Sequelist.
 
Thanks for the ideas guys. I had put entered this problem (where it belongs really) in the ASP forum and got my solution. We used a URLencode option before the values and that solved this problem ie:
<option value=&quot;<%=Server.URLEncode(&quot;Vets & Others&quot;)%>&quot;>Vets & others</option>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top