Moron Posted November 17, 2006 Share Posted November 17, 2006 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 More sharing options...
Barand Posted November 17, 2006 Share Posted November 17, 2006 [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']; Link to comment https://forums.phpfreaks.com/topic/27609-why-wont-my-image-display/#findComment-126322 Share on other sites More sharing options...
Moron Posted November 17, 2006 Author Share Posted November 17, 2006 [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. Link to comment https://forums.phpfreaks.com/topic/27609-why-wont-my-image-display/#findComment-126332 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.