Home » SQL & PL/SQL » SQL & PL/SQL » linking to an image on my webspace/hard drive to be displayed on a web site?
icon5.gif  linking to an image on my webspace/hard drive to be displayed on a web site? [message #231567] Tue, 17 April 2007 09:53 Go to next message
eleven
Messages: 5
Registered: April 2007
Location: UK
Junior Member
Hey,

Im making a basic website in where i want to have a products table displayed with an image at the end. There are 5 products.

This code does not work when creating the table:

CREATE TABLE PRODUCTS    
       (PRODUCT_ID NUMBER(2) NOT NULL,
        PRODUCT_NAME VARCHAR(30) NOT NULL,
        PRODUCT_FEATURES VARCHAR(500) NOT NULL,
        PRODUCT_RATING VARCHAR(5) NOT NULL,
        PRODUCT_PRICE VARCHAR(10) NOT NULL,
	PRODUCT_IMAGE VARCHAR NOT NULL,
	PRIMARY KEY (PRODUCT_ID));


I get this error:

ERROR at line 7:
ORA-00906: missing left parenthesis


Also when i tried it earler before messing with the code above, this code did NOT work:

UPDATE products SET PRODUCT_IMAGE ='jacket.jpg'
where PRODUCT_ID = '1';

UPDATE products SET PRODUCT_IMAGE ='boot.jpg'
where PRODUCT_ID = '2';

UPDATE products SET PRODUCT_IMAGE ='bindings.jpg'
where PRODUCT_ID = '3';

UPDATE products SET PRODUCT_IMAGE ='board.jpg'
where PRODUCT_ID = '4';

UPDATE products SET PRODUCT_IMAGE ='helmet.jpg'
where PRODUCT_ID = '5';


If anyone could highlight the errors in this code i would be VERY greatful, also does anyone know the code i would have to type into the HTML document to display the table?

Thanks for any help!
Re: linking to an image on my webspace/hard drive to be displayed on a web site? [message #231571 is a reply to message #231567] Tue, 17 April 2007 09:59 Go to previous messageGo to next message
BlackSwan
Messages: 25041
Registered: January 2009
Location: SoCal
Senior Member
>PRODUCT_IMAGE VARCHAR NOT NULL,
1) you should be using VARCHAR2 data types
2) what size is the string above?
Re: linking to an image on my webspace/hard drive to be displayed on a web site? [message #231576 is a reply to message #231571] Tue, 17 April 2007 10:06 Go to previous messageGo to next message
eleven
Messages: 5
Registered: April 2007
Location: UK
Junior Member
I know this is going to sound stupid; what is string size? Is it
varchar2[b](##)[/b]? 


I thought that becuase it's an image i didn't need to define one, or am i wrong?

[Updated on: Tue, 17 April 2007 10:07]

Report message to a moderator

Re: linking to an image on my webspace/hard drive to be displayed on a web site? [message #231754 is a reply to message #231567] Wed, 18 April 2007 05:54 Go to previous messageGo to next message
eleven
Messages: 5
Registered: April 2007
Location: UK
Junior Member
Anyone else have any idea on this? Embarassed
Re: linking to an image on my webspace/hard drive to be displayed on a web site? [message #231757 is a reply to message #231754] Wed, 18 April 2007 06:06 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
In Oracle, images can be stored in Binary Large Objects (BLOBs). So, you'd create your table like:
CREATE TABLE PRODUCTS    
       (PRODUCT_ID NUMBER(2) NOT NULL,
        PRODUCT_NAME VARCHAR(30) NOT NULL,
        PRODUCT_FEATURES VARCHAR(500) NOT NULL,
        PRODUCT_RATING VARCHAR(5) NOT NULL,
        PRODUCT_PRICE VARCHAR(10) NOT NULL,
	PRODUCT_IMAGE BLOB NOT NULL,
	PRIMARY KEY (PRODUCT_ID));


As for retrieving and storing BLOBs, I'm sure you'll find several useful threads on the board. And I would read the Oracle documentation on LOBs, their storage, ...

MHE
Re: linking to an image on my webspace/hard drive to be displayed on a web site? [message #231759 is a reply to message #231754] Wed, 18 April 2007 06:07 Go to previous messageGo to next message
ThomasG
Messages: 3189
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
In your example it is NOT an Image it is an varchar (allthough varchar2 would be better, as mentioned) with the FILENAME of the image.

So the length should be as long as you expect the filenames to get.

If you want to store the image itself in the db then you would have to use a BLOB (Binary Large Object)

But since it's for a webpage where the image is displayed when you put the right image filename in the html, it makes more sense to store only the name in the DB, not the image itself.
Re: linking to an image on my webspace/hard drive to be displayed on a web site? [message #231762 is a reply to message #231759] Wed, 18 April 2007 06:11 Go to previous messageGo to next message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
ThomasG wrote on Wed, 18 April 2007 13:07
But since it's for a webpage where the image is displayed when you put the right image filename in the html, it makes more sense to store only the name in the DB, not the image itself.

That is: if there is a location on the filesystem that is accessible from the outside because the images themselves need to be stored somewhere.

I have created websites - a long long time ago, in MOD/PLSQL - where everything was stored in the database: HTML (generated through HTP and HTF packages), images, PDF files, ... . I think it's not bad to keep images in the database.

MHE
Re: linking to an image on my webspace/hard drive to be displayed on a web site? [message #231925 is a reply to message #231567] Wed, 18 April 2007 20:17 Go to previous messageGo to next message
eleven
Messages: 5
Registered: April 2007
Location: UK
Junior Member
Can anyone tell me or give me a link to where i can find the information to actually link to the database from my website? ie: the HTML. I have some code but all i am seeing is a blank table. Here is the code im using:

<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
<tr>
<td>First</td>
<td>Surname</td>
<td>Position</td>
<td>Address</td>
<td>Tel_No</td>
<td>Start_Sal</td>
<td>Start_Date</td>


</tr>

<%
set Conn=Server.CreateObject("ADODB.Connection")
DS="Provider=MSDAORA.1;Password=#########;User ID=########;Data Source=#########;Persist Security Info=True"
Conn.Open DS
Sql = "select*from products" 
Set RS=Conn.Execute(sql)

Do while not rs.eof
%> <tr>
<td><%response.write(RS("ID Number"))%>&nbsp;</td>
<td><%response.write(RS("Name"))%>&nbsp;</td>
<td><%response.write(RS("Features"))%>&nbsp;</td>
<td><%response.write(RS("Rating"))%>&nbsp;</td>
<td><%response.write(RS("Price"))%>&nbsp;</td>
<td><%response.write(RS("Picture"))%>&nbsp;</td>
<% rs.MoveNext
loop
rs.close
set rs=nothing
conn.close
set conn=nothing %>

</tr>
</table>


Note: this code does not contain my information... it is just an example of the code i am using.

Is this code right? or am i missing something?





Re: linking to an image on my webspace/hard drive to be displayed on a web site? [message #232399 is a reply to message #231567] Fri, 20 April 2007 07:02 Go to previous messageGo to next message
eleven
Messages: 5
Registered: April 2007
Location: UK
Junior Member
Anyone got any ideas with this? Im still stuck with it Sad
Re: linking to an image on my webspace/hard drive to be displayed on a web site? [message #232408 is a reply to message #232399] Fri, 20 April 2007 07:30 Go to previous message
Maaher
Messages: 7062
Registered: December 2001
Senior Member
Have you tried the MSDN forum? There are some good ASP coders over there. And when I googled for it I found some useful links too.

Sorry, I'm not an ASP coder.

MHE
Previous Topic: differnce between views n materialized views
Next Topic: even & odd rows
Goto Forum:
  


Current Time: Tue Dec 06 12:16:33 CST 2016

Total time taken to generate the page: 0.05960 seconds