How To Open OLE on MS Access using PHP

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
jazzrhythm
Forum Newbie
Posts: 2
Joined: Wed Nov 16, 2005 7:54 am

How To Open OLE on MS Access using PHP

Post by jazzrhythm »

I've created a database on MSAccess. Created a table and included a field for OLE and wanted to display it on the web. Assuming I only have one item on the table...

Code: Select all

<tr>
<td valign="top">
<?php
$conn=odbc_connect('perfume','','');
if (!$conn)
{exit("Connection Failed: " . $conn);}
$sql="SELECT * FROM Perfume WHERE Sex='M'";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{exit("Error in SQL");}
while (odbc_fetch_row($rs))
{
$prodname=odbc_result($rs,"Product Name");
$brandname=odbc_result($rs,"Brand");
$price=odbc_result($rs,"Price");
$image=odbc_result($rs,"Image");

echo "<img src=$image>";
echo "<div>$prodname for Men by $brandname</div>";
}
odbc_close($conn);
?>
</td>
</tr>
I get the red X and lots of characters...
I believe there is something wrong with this line...

echo "<img src=$image>";

What do I need on there?

Thanks...
Burrito: Use php tags you should when Posting Code In The Forums you are
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Is $image a path to an image or an actual image stored in the database?

Mac
jazzrhythm
Forum Newbie
Posts: 2
Joined: Wed Nov 16, 2005 7:54 am

Post by jazzrhythm »

Thanks for the response...

$Image is an image stored in a database...

Give you more details on the database, maybe, it's where I did something wrong...

Used MS Access, created a Table then I have a Field named "Image" aside from the other Fields I created. And the Data Type is OLE Object. Saved Table, afterwards, opened Table. Right-Click on the cell under Image and selected Insert Object. Next, selected Create From File and then browsed to the image, it's *.bmp, Finally, clicked Ok.

What I have on the cell says, "Bitmap Image". When I double-clicked on it, Paint comes up and shows the image.
So, I believe I have an image there even if I don't see it on the cell.

Any ideas on how I can display that image on the browser?
Post Reply