Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 5th, 2007, 12:23 PM
Registered User
 
Join Date: Nov 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamic Image Problem

Can anyone spare a few moments to help me out. Whilst working my way through ‘Beginning ASP 3.0’ I am trying to construct some pages of my own. I need to display a jpg image from a reference to it which is stored in a database table. Later I intend to add a form which lets the user select the image they want but, at this stage I want to display, as default, the image which is named in the last record of the table.

The book doesn’t seem to deal with dynamic images at all so could you take a look at my code or suggest where I might go to find out how to do this.

Thanks

<% Option Explicit %>
<!-- METADATA TYPE="typelib"
        FILE="c:\program files\common files\system\ado\msado15.dll" -->

<html>
<head>
<title>Cracked Flag MuzikMaze</title></head>
<body>

<%
'To select and display the latest MuzikMaze puzzle by collecting
'the name of the jpg file from the last record in rant.mdb’s MuzikMaze table.

Dim objConn, objRS, strJPGFilename

Set objConn = Server.CreateObject("ADODB.Connection")
Set objRS = Server.CreateObject("ADODB.RecordSet")
objConn.Open = "Provider=Microsoft.Jet.OLEDB.4.0;"&_
            "Data Source=C:\databases\rant.mdb;"&_
            "Persist Security Info=False"
objRS.Open "Muzikmaze" , objConn, adopenStatic, adLockReadonly, adCmdTable
objRS.Movelast

strJPGFilename = "MuzikMaze/"& objRS("Filename") &".jpg"
Response.Write "<img src=" & strJPGFilename & ">"

objRS.Close
objConn.Close
Set objRS = Nothing
Set objConn = Nothing
%>

</body>
</html>


All I get in explorer is an image placeholder with a red cross. Obviously not right there!

If I change the key line Response.Write to…

Response.Write “<img sce = “ & EVAL(strJPGFilename) & “>”

Then I get this message…

Microsoft VBScript runtime (0x800A01F9)
Invalid or unqualified reference
/BegASP/CFRants/latestmaze.asp

Am I even on the right lines?

All help gratefully received

Pete
 
Old December 5th, 2007, 12:38 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Do:
Response.Write(strJPGFilename) what does that value equate to? Is it the valid path to your image? I am guessing it isnt.

hth.

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========
 
Old December 6th, 2007, 09:34 AM
Registered User
 
Join Date: Nov 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes - absolutely right. Stupid me - I was storing the pictures in the same place as the database instead of with the asp files. Simple as that!

Thanks for your help

Cheers

Pete
 
Old December 6th, 2007, 09:39 AM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

No problem glad it worked out for you. =]

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
grab dynamic image microbytes VB How-To 2 June 30th, 2008 08:21 PM
Dynamic image button Angel6784 ASP.NET 2.0 Basics 2 August 2nd, 2006 01:25 PM
dynamic changing of image pandad BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 0 January 5th, 2006 12:55 AM
Dynamic Image rajanikrishna Beginning PHP 1 October 8th, 2003 02:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.