I'm trying to display product cards with images on my website, instead of the image, there's a text with symbols as below.

Here is the index:

$q = "SELECT * FROM items" ;
$r = mysqli_query( $link, $q ) ;
if ( mysqli_num_rows( $r ) > 0 )
  # Display body section.
  echo '';
  while ( $row = mysqli_fetch_array( $r, MYSQLI_ASSOC ))
    echo '
    <div class="product_wrapper">
    <a href="#"><img src='. $row['item_image'].' class="product_image"></a>
    <button class="addtocart_button"><a href="added.php?id='.$row['item_id'].'">Add to cart</button>
    <p class="product_details"><a href="item.html">'. $row['item_name'] . '
    <p class="product_details">' . $row['item_price'] . '
    <div class="star_container">
        &#9733; &#9733; &#9733; &#9733; &#9733;

And here is a small chunk of what's displayed on the website. The image is stored as 'BLOB' data type in PHPmyAdmin. After inserting it into database, I've noticed the following message: 'Linting is disabled for this query because it exceeds the maximum length'.

��� )���������_&?���YNO�5�ᶌ�#>٫'�L���i�Mϗ'���3Z���J��S�����ZKp{\C�0A�����c����Wn�/֨��?�U!�� 

I've edited the image line like so:

<a href="#"><img src="data:image/jpeg;base64,'. base64_encode($row['item_image']).' class="product_image"></a>

This got rid of the symbols, however, the image still doesn't display (small error image).

1 Answers

Daniel Klas On

It looks like you're missing a double quote (") before the class= – nahanil