SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Thread: trouble with <%

  1. #1
    SitePoint Zealot trekmp's Avatar
    Join Date
    Dec 2005
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    trouble with <%

    Hi all,
    I'm storing some small amounts of ASP in a MySQL database something like

    Code:
    Here is a link please <a href="/<%=siteLink%>/pagename.asp">click it</a>
    Everything in the database is fine, but when I get the information out of the database on the screen the <%=siteLink%> is just coming out as text and not ASP, so the link looks like <a href="/<%=siteLink%>/pagename.asp">click it</a> instead of something like <a href="/sites/Mysite/pagename.asp">click it</a>

    At the top of my page I have siteLink="sites/Mysite", I need it like this so I can use it on different sites and pages, I don't want to have to store sites/mySite in the database.

    Is there a way round this, if so what, I really need this to work.
    Why do we exist? What is our purpose?
    >H2O Developments
    >USS Endeavour
    >Hosted@Servage

  2. #2
    Original Gangster silver trophy Thing's Avatar
    Join Date
    Oct 2000
    Location
    Philadelphia, PA
    Posts
    4,708
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    What type of server are you hosting this on? Did you name your page with .asp extension?

  3. #3
    SitePoint Zealot trekmp's Avatar
    Join Date
    Dec 2005
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Its running on IIS6 and yes my pages are filename.asp
    Why do we exist? What is our purpose?
    >H2O Developments
    >USS Endeavour
    >Hosted@Servage

  4. #4
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Has ASP been enabled?

  5. #5
    SitePoint Zealot trekmp's Avatar
    Join Date
    Dec 2005
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes all the pages are ASP and other asp functions run fine, just this bit doesn't
    Why do we exist? What is our purpose?
    >H2O Developments
    >USS Endeavour
    >Hosted@Servage

  6. #6
    SitePoint Enthusiast Northern Star's Avatar
    Join Date
    Aug 2006
    Location
    Cheshire, UK
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think I understand what your tring to do, but I'm not sure if it's possible.

    From what I gather you have...

    Code:
    Here is a link please <a href="/<%=siteLink%>/pagename.asp">click it</a>
    as an entry in your database?

    ...and when you 'write' this to the page, you want the value of 'siteLink' (which is defined on the .asp page itself) to be placed inbetween '...href="/' and '/pagename.asp...">...'

    Basically, your code '<%=siteLink%>' isn't being executed because it's being considered as part of the string its in.
    "If it ain't broken, don't fix it!"
    ----
    Northern Star - Web design, stategy & development.

  7. #7
    ALT.NET - because we need it silver trophybronze trophy dhtmlgod's Avatar
    Join Date
    Jul 2001
    Location
    Scotland
    Posts
    4,836
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The <%=siteLink%> should be parsed no problem as an ASP code block. Have you tried replacing it with <%Response.Write(siteLink)%> to see what happens? That's essentially what <%=...%> does, just less to type.

  8. #8
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Nelson BC
    Posts
    2,310
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you have this:
    Code:
    myString = "Here is a link please <a href=""/<%=siteLink%>/pagename.asp"">click it</a>"
    and you just output it, it won't work. You can't treat strings like ASP code, it doesn't work that way.

    Try this:
    Code:
    siteLink = "sites/Mysite"
    myString = "Here is a link please <a href=""/<%=siteLink%>/pagename.asp"">click it</a>"
    myString = Replace(myString, "<%=siteLink%>", siteLink)
    Response.Write myString

  9. #9
    SitePoint Zealot trekmp's Avatar
    Join Date
    Dec 2005
    Posts
    158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks jimfraser and everyone else, that works. Though I have another section that stores asp in a database and that executes for some reason, but never mind my main problem was solved.
    Why do we exist? What is our purpose?
    >H2O Developments
    >USS Endeavour
    >Hosted@Servage


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •