Jump to content

Why won't my image display?


Moron

Recommended Posts

At the top of my page, I have:

[code]header('Content-Type: image/jpeg');[/code]

My PHP code (this particular section) reads:

[code]
$conn = mssql_connect("ORSERVI","USERNAME","PASSWORD") or die ("Could Not Connect to Database.<br>Please Notify Computer Services.");
mssql_select_db('PerMaster',$conn);

$mypic=mssql_fetch_assoc(mssql_query("SELECT EI.[EmpPicture] FROM view_EmployeeInfo EI WHERE EI.[EMPNO] = '".$_POST['employeenumber']."'"));

$emppic = 'EI.[EmpPicture]';

$im = imagecreatefromstring($emppic);
if ($im !== false) {

imagejpeg($im);
}
else {
echo 'An error occurred.';
}[/code]

The result is:

[quote]
[b]Warning:[/b] imagecreatefromstring() [function.imagecreatefromstring]: Data is not in a recognized format. in [b]E:\User\Inetpub\wwwroot\employeeinformation\employeeinformationmenu.php [/b] on line [b]335[/b]
An error occurred.
[/quote]

I'm trying to display an image that's stored in an MS SQL database in binary format.

Anybody?

Link to comment
https://forums.phpfreaks.com/topic/27609-why-wont-my-image-display/
Share on other sites

[code]
$mypic=mssql_fetch_assoc(mssql_query("SELECT EI.[EmpPicture] FROM view_EmployeeInfo EI WHERE EI.[EMPNO] = '".$_POST['employeenumber']."'"));
[/code]

Bad habit to nest db functions like that.

You should change
$emppic = 'EI.[EmpPicture]';

to

$emppic = $mypic['EmpPicture'];
[quote author=Barand link=topic=115365.msg469746#msg469746 date=1163795769]
[code]
$mypic=mssql_fetch_assoc(mssql_query("SELECT EI.[EmpPicture] FROM view_EmployeeInfo EI WHERE EI.[EMPNO] = '".$_POST['employeenumber']."'"));
[/code]

Bad habit to nest db functions like that.

You should change
$emppic = 'EI.[EmpPicture]';

to

$emppic = $mypic['EmpPicture'];

[/quote]

Thanks. I changed it, but it didn't change the result I'm getting.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.