Print Page | Close Window

include error

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=16987
Printed Date: 29 March 2026 at 5:15pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: include error
Posted By: pilot99
Subject: include error
Date Posted: 21 October 2005 at 9:42pm
ok i have a weird probelm. i put this code to try to generate an include depending on the value in a database.
this code:
<%
'Create an ADO recordset object
Set rsGuestbook = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the
database
strSQL = "SELECT tblComments.include, tblComments.Comments,
tblComments.name, tblComments.nickname FROM tblComments WHERE
tblComments.Veiw like '1' ORDER BY tblComments.order;" 
rsGuestbook.Open strSQL, adoCon
response.Write("<!--#include file=""")
response.Write(rsGuestbook("include"))
response.write("""-->")
%>
its outputs nothing put when i go look at the source the following is in its place:
<!--#include file="1.asp"-->
and thats what i wwant but the probelm is that it doesnt show the page i told it to include.
any help?


-------------
http://www.globaltornado.com">



Replies:
Posted By: dpyers
Date Posted: 22 October 2005 at 11:37am
It has to do with how the asp interpreter loads the pages It expands.
Basically, there's no way to have as write an include statement and expand it at the same time. It's one of the reasons you can't have variables in an include statement which is basically what you're trying to do here.

EDIT: just realized I didn't give you a losution... lol
Try googling for asp dynamic include
There's several methods to work around this, none of them are elegant.

The most common one is to use if or case statements to execute the contents of one include or another. You just have to remember that the contents of all the includes will be expanded before executing the if or case statements.

The other common method is to always use the same include file but on some other asp page , use the fso to rewite the contents of the file with whatever code you want.





-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: pilot99
Date Posted: 26 October 2005 at 6:18pm
so is there any possible way to dynamicly include a file?

-------------
http://www.globaltornado.com">



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net