How to display image from mysql php

Please, help. I am trying to display an image of each user using the student ID BUT it displays unknown characters as an image on my page as shown below

% S $ PH ~ Q-} Y> ZTW?), G? r ~) 1WN {,! ^ J-94K

$sql_up="SELECT content FROM sp_uploads WHERE s_id= 'RC49557'"; $result_set=mysql_query($sql_up); while($row_up = mysql_fetch_array($result_set)) { $pp = $row_up['content']; } echo "<td> <img style=\"float:right; margin:5px; width:150px; height:150px; padding:10px; \" src=\" data:image/jpg;charset=utf8;base64,<?php echo $pp ?> \" /> </td>"; 
+5
source share
1 answer

It will be done. You do not need to open PHP tags inside PHP tags.

 $sql_up="SELECT content FROM sp_uploads WHERE s_id= 'RC49557'"; $result_set=mysql_query($sql_up); while($row_up = mysql_fetch_array($result_set)) { $pp = $row_up['content']; } echo "<td> <img style='float:right; margin:5px; width:150px; height:150px; padding:10px;' src='data:image/jpg;charset=utf8;base64, $pp' /> </td>"; 

I assume the img data is correct.

+3
source

Source: https://habr.com/ru/post/1239438/


All Articles