Advertisement

05.25.2008 at 08:49PM PDT, ID: 23431965
[x]
Attachment Details

Issue of embedding php into html with blob image

Asked by luvjazz in Miscellaneous Web Development, PHP Scripting Language, MySQL

Always a cinch to embed php into html, but not now.  I got the following code to work perfectly to successfully read a blob from a mysql db, on its own.  The issue, if I put the code into any kind of html, I get hieroglyphs.
-------
<?php
      $link=mysql_connect('myServer','username','password') or die('Could not connect: ' . mysql_error());
      mysql_select_db('luvjazz') or die('Could not connect to database');

    $query = "select * from upload";
      $result=mysql_query($query) or die('Query failed: ' . mysql_error());

      $type;
      
      while($line=mysql_fetch_array($result,MYSQL_ASSOC))
      {
            $type=$line['type'];
            $data=$line['content'];
      }
      
    Header( "Content-type: $type");
    echo $data;
?>
-------
This code works perfectly on its own, but not embedded into html or html embedded into it.  The image gets changed into hieroglyphs.  Can anyone tell me how come, and how to fix this issue?

Thanks in advance,
~ Luvjazz
Start Free Trial
[+][-]05.25.2008 at 08:57PM PDT, ID: 21644575

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.26.2008 at 02:42AM PDT, ID: 21645490

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Miscellaneous Web Development, PHP Scripting Language, MySQL
Sign Up Now!
Solution Provided By: bansidhar
Participating Experts: 2
Solution Grade: A
 
 
[+][-]05.26.2008 at 12:35PM PDT, ID: 21647760

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628