What is the problem in this code? I want to insert the images in the table, but it only shows crack or unidentified image.
code:
<?php
mysql_connect ("localhost","root","");
mysql_select_db("shop");
$res=mysql_query("select * from products");
echo "<table>";
while($row=mysql_fetch_array($res))
{
echo "<tr>";
echo "<td>";?> '<img src=" <?phpecho data:image/png;base64,' . base64_encode($row['image']) . '?> "height="100" width="100" />'<?php echo "</td>";
echo "</tr>";
}
echo "</table>";
?>
There are some errors. Try this line:
echo '<td><img src="data:image/png;base64,' . base64_encode($row['image']) . ' height="100" width="100" /></td>';
Btw. you should not use mysql_* as it is decreapted since PHP 5.5 and will be removed in the future. Use mysqli_* or PDO instead.
Replace your line
echo "<td>";?> '<img src=" <?phpecho data:image/png;base64,' . base64_encode($row['image']) . '?> "height="100" width="100" />'<?php echo "</td>";
Here quote issue and spacing issue like <?phpecho
and "height="100"
with this
echo "<td>";?> <img src=' <?php echo 'data:image/png;base64,' . base64_encode($row['image']); ?>' height="100" width="100" /><?php echo "</td>";