473,549 Members | 2,543 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get image from DB fails. Image are not returned correctly.

Hi,

I have a problem retreiving images from a MSSQL 2000 database with php. I wrote an ASP page using "response.binar ywrite" to get the same image, and this worked 100%. Therefore, the images in my database is not corrupt.
Only the top part of the image is returned to the client's browser window. Same result with both IE6 and Opera 7.11.
I guess the problem is header related, and I've tried to output different headers with no luck whatsoever.
Here is my php code:

getimagefromdb. php
-----------------------
<?php
error_reporting (E_ERROR);
header("Content-type: image/jpg");
$sql_servername = 'name_of_dbserv er';
$sql_user = 'sql_user_name' ;
$sql_userpw = 'sql_user_passw ord';
$db = 'database_name_ where_images_is ';

$query = "SELECT coverImage FROM dvds WHERE id = ".$_GET['ID'];
if (false != $conn = mssql_connect($ sql_servername, $sql_user,$sql_ userpw)) {
mssql_select_db ($db,$conn);
$rs = mssql_query($qu ery,$conn);
$arrImage = mssql_fetch_row ($rs);
mssql_close($co nn);
echo $arrImage[0];
}
?>
Next is a simple example of a page requesting image with ID=1:

index.php
-----------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
</head>
<body>
<table>
<tr>
<td>
Image: <img src="getimagefr omdb.php?ID=1" />
</td>
</tr>
</table>
</body>
</html>

I hope somebody can help me :-)
Thans a lot in advance.

Sincerely,
Bjarte

Jul 17 '05 #1
4 2747
In article <rT************ *******@news4.e .nsc.no>, Bjarte Andreassen wrote:

Only the top part of the image is returned to the client's browser
window. Same result with both IE6 and Opera 7.11. I guess the
problem is header related, and I've tried to output different
headers with no luck whatsoever.
Try getting the image using wget/lynx/curl just to make sure that it's
not a browser problem. telnet is also an option for testing this.
Here is my php code:

getimagefromdb. php
<?php
error_reporting (E_ERROR);
header("Content-type: image/jpg");


Consider adding a Content-length header.

Consider saving the image to file on the server and view the resulting
file in a browser, thus verifying the image routines are not broken.

Consider using flush().
Jul 17 '05 #2
Hi, and thanks for the clues...

I've verified that the image is NOT transferred completely with lynx. Besides, I've tested retreiving the same images with an ASP script, and that works 100%.
I've tested with flush() as well... No go...

I'm therefore still looking for the right solution here... :-D

Anyone???

Bjarte
Martin Wickman<wi***** @hotbrev.com> 18.09.2003 12:50:25 >>>
In article <rT************ *******@news4.e .nsc.no>, Bjarte Andreassen wrote:
Only the top part of the image is returned to the client's browser
window. Same result with both IE6 and Opera 7.11. I guess the
problem is header related, and I've tried to output different
headers with no luck whatsoever.
Try getting the image using wget/lynx/curl just to make sure that it's
not a browser problem. telnet is also an option for testing this.
Here is my php code:

getimagefromdb. php
<?php
error_reporting (E_ERROR);
header("Content-type: image/jpg");


Consider adding a Content-length header.

Consider saving the image to file on the server and view the resulting
file in a browser, thus verifying the image routines are not broken.

Consider using flush().
Jul 17 '05 #3

In article <uJ************ *******@news4.e .nsc.no>, bjartea @ hotmail.com wrote:

Please refrain from top posting. It sucks.
Hi, and thanks for the clues...

I've verified that the image is NOT transferred completely with
lynx. Besides, I've tested retreiving the same images with an ASP
script, and that works 100%. I've tested with flush() as well... No
go...


Did you try:

Consider saving the image to file on the server and view the
resulting file in a browser, thus verifying the image routines are
not broken.

Also, did you try:

Consider adding a Content-length header.
Jul 17 '05 #4
Yes, I included "datalength(cov erImage) as Image" in my SQL query, and used the result in the Content-length header.
Images are still not retreived correctly. Approx 10-20% of the image raster are displayed in the browser (different number of raster returned on different images).

Next, I will try your last suggestion, and save the image to file. But I'm convinced that the images are okay, because they look absolute perfect when I retreive them with an asp script instead of php. Go figure... :-/

I've tested this with php 4.3.2 and 4.3.3, by the way....
I've also tested this on both IIS6 and Apache2.0.
Anyways, thanks a lot...

Regards,
Bjarte
Martin Wickman<wi***** @hotbrev.com> 18.09.2003 23:41:57 >>>

In article <uJ************ *******@news4.e .nsc.no>, bjartea @ hotmail.com wrote:

Please refrain from top posting. It sucks.
Hi, and thanks for the clues...

I've verified that the image is NOT transferred completely with
lynx. Besides, I've tested retreiving the same images with an ASP
script, and that works 100%. I've tested with flush() as well... No
go...


Did you try:

Consider saving the image to file on the server and view the
resulting file in a browser, thus verifying the image routines are
not broken.

Also, did you try:

Consider adding a Content-length header.
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4424
by: Rob Manger | last post by:
Hi All, I am hoping someone can help me. I am trying to setup my main page so that when the user moves the mouse over an image, it changes the source (got this working). When the user CLICKS on the image (it is a link to the content page) it changes to a third image AND STAYS THERE. ie: so the iamge won't change back to the omouseoff...
1
1323
by: NMA | last post by:
I have a Visual Studio 6 project that was building correctly. I took a day off of that project to install .NET 03 for another project, then returned to my VS6 project the next day. Without any modifications made to the code, the VS6 project now fails to build. I am seeing the following: error C2653: 'XXXXXX' : is not a class or namespace...
5
4131
by: William Starr Moake | last post by:
I want to adapt the following alert script into an insert image dialog in my WYSIWYG editor, but I can't get it to write an image tag correctly. <head> <script> function getImageDims(imgurl) { var oImage = new Image(); oImage.onload = new Function(
7
18891
by: Andrew Poulos | last post by:
I'm using the following code to create a small table with one column and two rows. An image goes into the first cell. //create table var t = document.createElement("TABLE"); t.style.position = "absolute"; t.style.left = "100px"; t.style.top = "100px"; t.style.width = "200px";
2
6348
by: mike | last post by:
I've spent a couple of days on this and I'm to the "bang-my-head 'gainst the monitor and babble in tongues" mode. First - SuSE Pro 9.3, Linux 2.6.11.4-21.7, Apache 2.0.53, PHP 4.3.10 I have sendmail running on the local server - mail from unix (1) mail and mutt work locally on the server. This is, specifically, sending mail to a...
12
2297
by: Joe Stanton | last post by:
Hello Group I have a query that works in Oracle and SQL Server, but fails in Microsoft Access. The query is: SELECT data fromTABLE1 WHERE data>='A&' AND data<'A''' Here is my sample data:
23
5893
by: Peter | last post by:
I have a problem with a page show_image.asp that returns a jpg image under Windows XP Pro SP2. The page sets content type as: Response.ContentType = "image/jpg" While this works perfectly fine on most machines, on some machines I experience this problem: When loading the page a window pops up that asks if I want to open the document...
4
1798
by: Mark S. | last post by:
Hello, On a high volume page we have the following JavaScript: img = new Image() img.src = 'http://myserver.com/count.aspx?x=1'; and it works fine, but now we've added: img.onload = myImgLoaded and it fails on IE and FF. The reason being it's not returning a proper
4
11532
by: Ben | last post by:
Hello, I'm trying to get an image from a webserver here in the network. I managed to create a socket connection and filter out the response headers. I load the body of the reply into a MemoryStream, but when trying to use Image.FromStream(), I get an invalid argument error. Here is my code: public Image loadImage(DateTime time)
0
7461
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7730
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7823
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5381
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5101
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3509
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1956
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1068
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.