Hello Group,
Perhaps you can help me. I have a mysql db, that holds images.
Images are encoded using base64_decode/encode, etc. Image data seems
fine.
I have a view.php page that is supposed to show the image, and an
image.php page that accesses
the database, retrives the image data, and then (theoretically) prints
the decoded data to the page.
below is the view.php page code: problem area the img tag src no
worky.
What am i missing (having stolen the idea for this from the web!!!!
thanks,
eric
/************************************************** *****************/
<html>
<head>
<title>Get The Image</title>
<link rel="stylesheet" type="text/css" href="css/csssmall.css" />
</head>
<body>
<center><img src="testimage/Sunset.jpg" width="300" border="1"
alt="Image of Sunset"></center>
<p class="para-color"><?php echo 'Beautiful Image' ?></p>
<br>
<center><img src="image.php?img=3" width="200" border="1" alt="Image of
Thelma Todd"></center>
<p class="para-color"><?php echo '\'Nother Beautiful Image' ?></p>
</body>
</html>
/************************************************** ****************/
below is the image.php code:
/************************************************** ********************
<?php
$dbhost = 'localhost';
$dbuser = 'auser';
$dbpass = 'apassword';
$dbcnx = @mysql_connect($dbhost,$dbuser,$dbpass);
if (!$dbcnx)
{
echo( "connection to database server failed!");
exit();
}
if (! @mysql_select_db("portfolio") )
{
echo( "Image Database Not Available!" );
exit();
}
?>
<?php
$img = $_REQUEST["img"];
?>
<?php
$result = @mysql_query("SELECT * FROM images WHERE id=" . $img . "");
if (!$result)
{
echo("Error performing query: " . mysql_error() . "");
exit();
}
while ( $row = @mysql_fetch_array($result) )
{
$imgid = $row["id"];
$encodeddata = $row["sixfourdata"];
$title = $row['title'];
}
?>
<?php
//echo $encodeddata;print??
echo base64_decode($encodeddata);
//echo $prefix . $encodeddata;
?>
/************************************************** *********************** 7 5342
eholz1 wrote :
Hello Group,
Perhaps you can help me. I have a mysql db, that holds images.
Images are encoded using base64_decode/encode, etc. Image data seems
fine.
I have a view.php page that is supposed to show the image, and an
image.php page that accesses
the database, retrives the image data, and then (theoretically) prints
the decoded data to the page.
below is the view.php page code: problem area the img tag src no
worky.
What am i missing (having stolen the idea for this from the web!!!!
thanks,
eric
/************************************************** *****************/
<html>
<head>
<title>Get The Image</title>
<link rel="stylesheet" type="text/css" href="css/csssmall.css" />
</head>
<body>
<center><img src="testimage/Sunset.jpg" width="300" border="1"
alt="Image of Sunset"></center>
<p class="para-color"><?php echo 'Beautiful Image' ?></p>
<br>
<center><img src="image.php?img=3" width="200" border="1" alt="Image of
Thelma Todd"></center>
<p class="para-color"><?php echo '\'Nother Beautiful Image' ?></p>
</body>
</html>
/************************************************** ****************/
below is the image.php code:
/************************************************** ********************
<?php
$dbhost = 'localhost';
$dbuser = 'auser';
$dbpass = 'apassword';
$dbcnx = @mysql_connect($dbhost,$dbuser,$dbpass);
if (!$dbcnx)
{
echo( "connection to database server failed!");
exit();
}
if (! @mysql_select_db("portfolio") )
{
echo( "Image Database Not Available!" );
exit();
}
?>
<?php
$img = $_REQUEST["img"];
?>
<?php
$result = @mysql_query("SELECT * FROM images WHERE id=" . $img . "");
if (!$result)
{
echo("Error performing query: " . mysql_error() . "");
exit();
}
while ( $row = @mysql_fetch_array($result) )
{
$imgid = $row["id"];
$encodeddata = $row["sixfourdata"];
$title = $row['title'];
}
?>
<?php
//echo $encodeddata;print??
echo base64_decode($encodeddata);
//echo $prefix . $encodeddata;
?>
/************************************************** ***********************
Why do you always open/close the PHP tags? There's no use for it.
The matter in here is that you forgot to tell your browser that the data you're
sending are not plain text or PHP rendering, but a picture.
Do it by writing :
header('Content-Type: image/jpeg');
echo base64_decode($encodeddata);
--
Naixn http://fma-fr.net
eholz1 wrote:
Hello Group,
Perhaps you can help me. I have a mysql db, that holds images.
Images are encoded using base64_decode/encode, etc. Image data seems
fine.
And I'm curious why your data is base64 encoded rather than simply
stored as a binary blob.
base64 is quite inefficient (takes up a lot more storage space).
Hello bkdotcom
do I have to encode/decode the image data if I use a "binary blob"?,
tnx,
eholz1
BKDotCom wrote:
eholz1 wrote:
Hello Group,
Perhaps you can help me. I have a mysql db, that holds images.
Images are encoded using base64_decode/encode, etc. Image data seems
fine.
And I'm curious why your data is base64 encoded rather than simply
stored as a binary blob.
base64 is quite inefficient (takes up a lot more storage space).
Hello naixn,
I removed the "extra" php tags (that is what I get from copying someone
else's code!)
and now the image displays. thanks. I will look at blob vs. base64
Thanks to all,
eholz1
naixn wrote:
eholz1 wrote :
Hello Group,
Perhaps you can help me. I have a mysql db, that holds images.
Images are encoded using base64_decode/encode, etc. Image data seems
fine.
I have a view.php page that is supposed to show the image, and an
image.php page that accesses
the database, retrives the image data, and then (theoretically) prints
the decoded data to the page.
below is the view.php page code: problem area the img tag src no
worky.
What am i missing (having stolen the idea for this from the web!!!!
thanks,
eric
/************************************************** *****************/
<html>
<head>
<title>Get The Image</title>
<link rel="stylesheet" type="text/css" href="css/csssmall.css" />
</head>
<body>
<center><img src="testimage/Sunset.jpg" width="300" border="1"
alt="Image of Sunset"></center>
<p class="para-color"><?php echo 'Beautiful Image' ?></p>
<br>
<center><img src="image.php?img=3" width="200" border="1" alt="Image of
Thelma Todd"></center>
<p class="para-color"><?php echo '\'Nother Beautiful Image' ?></p>
</body>
</html>
/************************************************** ****************/
below is the image.php code:
/************************************************** ********************
<?php
$dbhost = 'localhost';
$dbuser = 'auser';
$dbpass = 'apassword';
$dbcnx = @mysql_connect($dbhost,$dbuser,$dbpass);
if (!$dbcnx)
{
echo( "connection to database server failed!");
exit();
}
if (! @mysql_select_db("portfolio") )
{
echo( "Image Database Not Available!" );
exit();
}
?>
<?php
$img = $_REQUEST["img"];
?>
<?php
$result = @mysql_query("SELECT * FROM images WHERE id=" . $img . "");
if (!$result)
{
echo("Error performing query: " . mysql_error() . "");
exit();
}
while ( $row = @mysql_fetch_array($result) )
{
$imgid = $row["id"];
$encodeddata = $row["sixfourdata"];
$title = $row['title'];
}
?>
<?php
//echo $encodeddata;print??
echo base64_decode($encodeddata);
//echo $prefix . $encodeddata;
?>
/************************************************** ***********************
Why do you always open/close the PHP tags? There's no use for it.
The matter in here is that you forgot to tell your browser that the data you're
sending are not plain text or PHP rendering, but a picture.
Do it by writing :
header('Content-Type: image/jpeg');
echo base64_decode($encodeddata);
--
Naixn http://fma-fr.net
eholz1 wrote:
Hello Group,
Perhaps you can help me. I have a mysql db, that holds images.
Images are encoded using base64_decode/encode, etc. Image data seems
fine.
I have a view.php page that is supposed to show the image, and an
image.php page that accesses
the database, retrives the image data, and then (theoretically) prints
the decoded data to the page.
below is the view.php page code: problem area the img tag src no
worky.
What am i missing (having stolen the idea for this from the web!!!!
thanks,
eric
/************************************************** *****************/
<html>
<head>
<title>Get The Image</title>
<link rel="stylesheet" type="text/css" href="css/csssmall.css" />
</head>
<body>
<center><img src="testimage/Sunset.jpg" width="300" border="1"
alt="Image of Sunset"></center>
<p class="para-color"><?php echo 'Beautiful Image' ?></p>
<br>
<center><img src="image.php?img=3" width="200" border="1" alt="Image of
Thelma Todd"></center>
<p class="para-color"><?php echo '\'Nother Beautiful Image' ?></p>
</body>
</html>
/************************************************** ****************/
below is the image.php code:
/************************************************** ********************
<?php
$dbhost = 'localhost';
$dbuser = 'auser';
$dbpass = 'apassword';
$dbcnx = @mysql_connect($dbhost,$dbuser,$dbpass);
if (!$dbcnx)
{
echo( "connection to database server failed!");
exit();
}
if (! @mysql_select_db("portfolio") )
{
echo( "Image Database Not Available!" );
exit();
}
?>
<?php
$img = $_REQUEST["img"];
?>
<?php
$result = @mysql_query("SELECT * FROM images WHERE id=" . $img . "");
if (!$result)
{
echo("Error performing query: " . mysql_error() . "");
exit();
}
while ( $row = @mysql_fetch_array($result) )
{
$imgid = $row["id"];
$encodeddata = $row["sixfourdata"];
$title = $row['title'];
}
?>
<?php
//echo $encodeddata;print??
echo base64_decode($encodeddata);
//echo $prefix . $encodeddata;
?>
/************************************************** ***********************
I have never like storing images in databases - I generally have a special
directory where I have images that are named numberically or sometimes some type
of unique_id. Then I store the the decription and filename only in the database
and use some sort of server-side processing to "display" the appropriate image.
Requires much less space in the database and much less strain on the db engine
to retrieve that much information - especially if you need to do the same thing
hundreds of times a day.
--
Michael Austin.
Database Consultant
eholz1 wrote:
Hello bkdotcom
do I have to encode/decode the image data if I use a "binary blob"?,
tnx,
eholz1
BKDotCom wrote:
>>eholz1 wrote:
>>>Hello Group,
Perhaps you can help me. I have a mysql db, that holds images. Images are encoded using base64_decode/encode, etc. Image data seems fine.
And I'm curious why your data is base64 encoded rather than simply stored as a binary blob. base64 is quite inefficient (takes up a lot more storage space).
No.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attglobal.net
==================
Michael Austin wrote:
eholz1 wrote:
>Hello Group,
Perhaps you can help me. I have a mysql db, that holds images. Images are encoded using base64_decode/encode, etc. Image data seems fine. I have a view.php page that is supposed to show the image, and an image.php page that accesses the database, retrives the image data, and then (theoretically) prints the decoded data to the page. below is the view.php page code: problem area the img tag src no worky.
What am i missing (having stolen the idea for this from the web!!!! thanks, eric /************************************************** *****************/ <html> <head> <title>Get The Image</title> <link rel="stylesheet" type="text/css" href="css/csssmall.css" /> </head> <body> <center><img src="testimage/Sunset.jpg" width="300" border="1" alt="Image of Sunset"></center> <p class="para-color"><?php echo 'Beautiful Image' ?></p> <br> <center><img src="image.php?img=3" width="200" border="1" alt="Image of Thelma Todd"></center> <p class="para-color"><?php echo '\'Nother Beautiful Image' ?></p> </body> </html> /************************************************** ****************/
below is the image.php code: /************************************************** ******************** <?php $dbhost = 'localhost'; $dbuser = 'auser'; $dbpass = 'apassword'; $dbcnx = @mysql_connect($dbhost,$dbuser,$dbpass);
if (!$dbcnx) { echo( "connection to database server failed!"); exit(); } if (! @mysql_select_db("portfolio") ) { echo( "Image Database Not Available!" ); exit(); } ?> <?php $img = $_REQUEST["img"]; ?>
<?php $result = @mysql_query("SELECT * FROM images WHERE id=" . $img . "");
if (!$result) { echo("Error performing query: " . mysql_error() . ""); exit(); } while ( $row = @mysql_fetch_array($result) ) { $imgid = $row["id"]; $encodeddata = $row["sixfourdata"]; $title = $row['title']; } ?> <?php //echo $encodeddata;print?? echo base64_decode($encodeddata); //echo $prefix . $encodeddata; ?> /************************************************** ***********************
I have never like storing images in databases - I generally have a
special directory where I have images that are named numberically or
sometimes some type of unique_id. Then I store the the decription and
filename only in the database and use some sort of server-side
processing to "display" the appropriate image.
Requires much less space in the database and much less strain on the db
engine to retrieve that much information - especially if you need to do
the same thing hundreds of times a day.
It's not that much different in storage space, and access isn't all the
much different.
I find there can be advantages to storing in the database, as well as
disadvantages. I use them sometimes, and other times not.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attglobal.net
================== This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: apchar |
last post by:
I am trying to use php as a kind of servlet to act as a middle man
between a java applet and mysql. I know java has jdbc but it's flakey
and painful. php access to mysql is much nicer. So I have:...
|
by: adam |
last post by:
Hi, I have an issue that i just cant seem to figure out hope some one
can help.
right i am getting people to input the own images directly into a blob
within a mysql database. then on the next...
|
by: david |
last post by:
Hi,
I have asp pages running from a MySQL database.
I have placed a path in the required field (although not quite sure on
the correct format).
My asp page is just displaying the text path...
|
by: John Smith |
last post by:
I know that uploading an image to a database has been covered, oh, about 3
trillion times. However, I haven't found anything covering uploading to a
MySQL database with .net. Please don't...
|
by: Objectifnet |
last post by:
What I really want to do is to be able to link two pages together using an ID, The table involved displays an image stored on the File Server that has the image details stored in the Database called....
|
by: tanyali |
last post by:
my .png files r stored as a blob in MySql,
I wanna to display them out in php through a web browser.
this is part of code (in php):
---after connect to database ,
$dbQuery=" select name,...
|
by: alexseow |
last post by:
Query.asp
<%@ LANGUAGE="VBSCRIPT" %>
<!-- #include file="../../includes/dbconn.asp"-->
<%
dim MyRs, sqlstr, MyConn
Response.Expires = 0
Response.Buffer = TRUE
Response.Clear
|
by: mirianCalin |
last post by:
i am doing a site for appliance center..
i need to display all the products that the company offers, but my problem is that i cant display ALL the images in my database.. the first entry on the...
|
by: msmjsuarez |
last post by:
how can i display both image and other information in the web page using php?
i'm using mysql database.
I do displaying the image only but i want to display both other information from the database...
|
by: erikbower65 |
last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA:
1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
|
by: kcodez |
last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
|
by: DJRhino1175 |
last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this -
If...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: DJRhino |
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: lllomh |
last post by:
How does React native implement an English player?
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
|
by: DJRhino |
last post by:
Was curious if anyone else was having this same issue or not....
I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
| |