Welcome to WebmasterWorld Guest from 34.204.194.190

Forum Moderators: ocean10000

Message Too Old, No Replies

ASP Syntax Problem

Fitting a global variable into a query

     
7:46 pm on Aug 19, 2002 (gmt 0)

Senior Member from GB 

WebmasterWorld Senior Member brotherhood_of_lan is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 30, 2002
posts:5026
votes: 57


I'm not too great with ASP, and most of what is produced is courtesy of Frontpage with a little tweaking in Notepad to stop the program abusing the code ;)

The prog is good for quickly getting some database results on the go...the query is run of the mill...a primary key equalling "whatever" to display the particular contents of the page.

The primary key will be the URL, since all pages will need a unique URL. I found out to acquire the URL I can use the below request

<%= Request.ServerVariables("URL") %>

Using this code simply prints it out, which is fine. But I want to put the contents of that variable in the HERE bit below

fp_sQry="SELECT * FROM table WHERE (id = 'HERE')"

Hopefully it will save some hassle over the long term, but I'm not sure of the syntax here....I know I simply can't copy and paste code bit #1 into the query....as it thinks all the code inside the single quotes is the WHERE statement.

Can an ASP wizard be so kind to correct me on the syntax to fit the funky variable into the query? :)

Thanks for the replies in advance!

7:53 pm on Aug 19, 2002 (gmt 0)

Full Member

10+ Year Member

joined:Feb 28, 2001
posts:208
votes: 0


try something along the lines of:

<%
myURL = Request.ServerVariables("URL")

fp_sQry = "SELECT * FROM table WHERE (id = '" & myURL & "')"
%>

or

<%
fp_sQry = "SELECT * FROM table WHERE (id = '" & Request.ServerVariables("URL") & "'")
%>

8:23 pm on Aug 19, 2002 (gmt 0)

Senior Member from GB 

WebmasterWorld Senior Member brotherhood_of_lan is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 30, 2002
posts:5026
votes: 57


Thanks for the speedy reply evinrude ;)

I get a "page cannot be displayed" with the error "Expected end of statement" with both your methods.

I noticed by adding an extra comma after the id= bit- I managed to get the page displayed using your 2nd example, though I get this :

Syntax error (missing operator) in query expression '(id ='.

Just a little syntax error? :) I would not know any better....

/added
The whole statement is used in an included .asp page if that applies at all in the case of acquiring the URL here

8:31 pm on Aug 19, 2002 (gmt 0)

Junior Member

10+ Year Member

joined:July 3, 2002
posts:82
votes: 0


WHERE (id = '" & Request.ServerVariables("URL") & "'")

You could try without the brackets around the WHERE clause:

WHERE id = '" & Request.ServerVariables("URL") & "'"

8:33 pm on Aug 19, 2002 (gmt 0)

Senior Member from GB 

WebmasterWorld Senior Member brotherhood_of_lan is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 30, 2002
posts:5026
votes: 57


That is it on the nail...it's beautiful when the page loads like it should ;)

Thanks to the both of ya, it's appreciated

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members