#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2012
    Posts
    4
    Rep Power
    0

    Call same image multiple times on one page


    Hi again all,

    I have come upon another problem which I am having trouble with.
    I am used to php and am trying to get my head around asp.

    I have a function which calls an image from my database however if I try to call that image more than once on the same page it does not show up, there is no error it is just not appearing.

    In the code below I have [Image1] showing fine but in the sections where Image2 - Image5 are there is a blank box showing, if I click on the blank box it opens a pop-up displaying the actual image as intended.

    If I change Image2 to read Image1 again only one instance of Image1 will be displayed.

    Any help would be greatly appreciated.

    The code in question is:

    Code:
     
    <%
    Set MyCmd = Server.CreateObject("ADODB.Command")				MyCmd.ActiveConnection = MyConn
    MyCmd.CommandText = "SELECT NewsID, Title, DateUploaded, Image1, Image2, Image3, Image4, Image5, Article FROM DB WHERE NewsID = ?"
    							MyCmd.Parameters.Append MyCmd.CreateParameter("", 3, 1, , request("id"))
    Set RSNews = Server.CreateObject("ADODB.RecordSet")
    RSNews.Open MyCmd
    Do While Not RSNews.EOF
    %>
                                <h2><%=RSNews("Title")%></h2>
                                  <img src="images/projects/<%=RSNews("Image1")%>" width="150" alt="" border="0" align="left" class="leftimg"/>
                                	<h2>Gallery</h2>
                                    <p>Click an image below to view full size.</p>
                                <div id="portfoliobox">
                                        <a href="images/projects/<%=RSNews("Image2")%>" class="thickbox"><img src="images/projects/<%=RSNews("Image2")%>" width="110" border="0" alt="" align="left" class="leftimg" /></a>
                                        <a href="images/projects/<%=RSNews("Image3")%>" class="thickbox"><img src="images/projects/<%=RSNews("Image3")%>" width="110" border="0" alt="" align="left" class="leftimg" /></a>
                                        <a href="images/projects/<%=RSNews("Image4")%>" class="thickbox"><img src="images/projects/<%=RSNews("Image4")%>" width="110" border="0" alt="" align="left" class="leftimg" /></a>
                                        <a href="images/projects/<%=RSNews("Image5")%>" class="thickbox"><img src="images/projects/<%=RSNews("Image5")%>" width="110" border="0" alt="" align="left" class="leftimg" /></a>
    </div>
    							<p><%=RSNews("Article")%></p>
  2. #2
  3. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,445
    Rep Power
    4539
    If your code has any "on error resume next" statement remove it so errors don't get supressed.

    Copy the image blob to a local variable or file, ADO sometimes only allows a single code reference to a blob field.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2012
    Posts
    4
    Rep Power
    0
    Originally Posted by Doug G
    If your code has any "on error resume next" statement remove it so errors don't get supressed.

    Copy the image blob to a local variable or file, ADO sometimes only allows a single code reference to a blob field.
    Hi Doug,

    Once again thankyou for responding to my questions,
    I have removed any instances of "on error resume next" but am still getting the same problem, I failed to mention in my previous post that the old server was running ii6 the new server is running ii7.5 I have enabled classic asp and my other forms and scripts work, I do not know if that holds any clues to this puzzle, but information is key.

    As i said before I am new to asp, are you able to give me an example please on "Copy the image blob to a local variable or file, ADO sometimes only allows a single code reference to a blob field."
  6. #4
  7. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,445
    Rep Power
    4539
    I didn't look closely enough, it looks like you're only storing the path to the images in the db.

    It's possible to store the actual image binary in a db as a "BLOB" field (Binary Large Object). ADO is Microsoft ActiveX Data Objects, which is the subsystem you're using to query the database and get a recordset. If you retrieve a BLOB field in a recordset, sometimes your asp code will only be allowed to refer to rs("blobfield") only one time, the blob data goes away after the 1st time it's read from the recordset.

    But that's not your problem it seems.

    First I'd use a database query tool to verify the correct data is stored in the database columns, and also verify the paths to the images are valid on your new server.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2012
    Posts
    4
    Rep Power
    0
    Hi Doug,

    Thankyou for your helpfull advice once again, I have managed to resolve the issue to some extent but I think it is time to forget the old code now and either rebuild the site using PHP or asp.net.

    Once again thankyou for taking the time to assist me

IMN logo majestic logo threadwatch logo seochat tools logo