Jump to content

Problem with outputting image from blob


DWP

Recommended Posts

[code]<?php
$result=mysql_query("SELECT * FROM  profiles");
while($M = mysql_fetch_array($result)){
//
if ($M[img] !== "") {
header("Content-type: image/jpeg");
echo "$M[img]";
exit ();
        }
echo "<table>
  <tr>
    <td colspan=\"2\">&nbsp;&nbsp; {$M[Nick]} </td>
  </tr>
  <tr valign=\"top\">
    <td><table border=\"0\">
      <tr>
        <td><img src=\"{$M[img]}\" width=\"130\" height=\"170\" alt=\"\" /></td>
      </tr>
    </table></td>
    <td><table width=\"100%\" border=\"0\">
      <tr>
        <td>Name: {$M['First']} {$M['Last']} </td>
      </tr>
      <tr>
        <td>Age: {$M['Age']} </td>
      </tr>
      <tr>
        <td>Sex: {$M['Sex']} </td>
      </tr>
      <tr>
        <td>Location: {$M['Location']} </td>
      </tr>
    </table></td>
  </tr>
</table>";
}
?>
[/code]
Link to comment
https://forums.phpfreaks.com/topic/31347-problem-with-outputting-image-from-blob/
Share on other sites

For starters, you trying to use an array inside a string like a scalar...they don't use quite the same syntax for interpolation...

[code]echo "$M[img]";[/code]

Should be

[code]echo $M['img'];[/code]

Notice you don't need the double quotes around the whole thing...but you do need quotes inside the square brackets to properly index an associative field...

If you have some reason where you absolutely need the array inside a string and wish to use interpolation still...I believe the syntax is...

[code]echo "${M['img']}";[/code]

Again...you still need quotes around the associative index but you also need curly brackets...

Cheers :)
updated code but it only shows pic not the rest?

[code]
<?php
$result=mysql_query("SELECT * FROM  profiles");
while($M = mysql_fetch_array($result)){
if ($M['img'] !== "") {
header("Content-type: image/jpeg");
echo $M['img'];
exit ();
        } else {
echo "No Image"; }
echo "<table>
  <tr>
    <td colspan=\"2\">&nbsp;&nbsp; {$M[Nick]} </td>
  </tr>
  <tr valign=\"top\">
    <td><table border=\"0\">
      <tr>
        <td><img src=\"{$M['img']}\" width=\"130\" height=\"170\" alt=\"\" /></td>
      </tr>
    </table></td>
    <td><table width=\"100%\" border=\"0\">
      <tr>
        <td>Name: {$M['First']} {$M['Last']} </td>
      </tr>
      <tr>
        <td>Age: {$M['Age']} </td>
      </tr>
      <tr>
        <td>Sex: {$M['Sex']} </td>
      </tr>
      <tr>
        <td>Location: {$M['Location']} </td>
      </tr>
    </table></td>
  </tr>
</table>";
}
?>
[/code]
thats what it shows [url=http://www.pwdinc.ca/PWD/mem.php]www.pwdinc.ca/PWD/mem.php[/url] dose put the rest of the info in
  • 2 weeks later...

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.