Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - include error
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

include error

 Post Reply Post Reply
Author
pilot99 View Drop Down
Groupie
Groupie


Joined: 05 July 2004
Status: Offline
Points: 167
Post Options Post Options   Thanks (0) Thanks(0)   Quote pilot99 Quote  Post ReplyReply Direct Link To This Post Topic: include error
    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?
Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post 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.





Edited by dpyers - 22 October 2005 at 11:52am

Lead me not into temptation... I know the short cut, follow me.
Back to Top
pilot99 View Drop Down
Groupie
Groupie


Joined: 05 July 2004
Status: Offline
Points: 167
Post Options Post Options   Thanks (0) Thanks(0)   Quote pilot99 Quote  Post ReplyReply Direct Link To This Post Posted: 26 October 2005 at 6:18pm
so is there any possible way to dynamicly include a file?
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.