Click to See Complete Forum and Search --> : Rotate me!!


scammeh^
03-11-2005, 03:40 PM
Hi! Im trying to use the following code to rotate a 'quote of the day'.
<%
set cr=server.createobject("MSWC.ContentRotator")
response.write(cr.ChooseContent("quote.txt"))
%>

Now because im using a template system, and this code is within the uneditable region, I want this code to work universally on all pages. However, pages within a subdirectory obviously throw up a 'File not Found' error. When I try replacing "quote.txt" with "http://www.mysite.com/quote.txt" it throws up the error: 'Invalid Path Character' 'An invalid character was specified in the Path parameter for the MapPath method.'

Does anyone have any ideas on how I can get a standard URL working for all pages? I could edit each file individually and point it to the quote file, but that would defeat the point of using a template system.

Ta

lmf232s
03-11-2005, 04:58 PM
try to make it a function and put it in an include file.
You can also try to path to it using the UNC name and not the url
\\serverName\inetpub\...........\quote.txt

scammeh^
03-13-2005, 07:05 AM
Thanks fot your reply lmf232s. Sorry, its probably me just being stupid, but I cant grasp how it would work making it a function and putting it in an include file? Surely that would give the same problem as the path would still be relative to the page its included in. Do you mean linking it to a seperate script file?

Also, as I dont knw the UNC path on the server, is there a piece of code, or a way of showing me the current directory in UNC format?

Thanks for your help

scammeh^
03-20-2005, 08:18 AM
nope?

phpnovice
03-20-2005, 08:43 AM
Because you say the file is located outside of your web structure, only a physical path for the file is going to suffice. Thus, you cannot use a URL or a relative path of any sort. Relative paths always have their basis as the web root folder. The following server environment variable contains the physical path to your web root folder.

Request.ServerVariables("APPL_PHYSICAL_PATH")

Conceivably, if your file is on the same server and harddrive, you could use script to remove the name of your web root folder from this physical path and, then, construct the physical path to your file from the remainder.