-1

I have created a simple display website for my Kodi database. The data for this site comes from a MySQL database.

When I use this code: (to display a cover from a Album)

<td><?php echo '<img src='.$row['url']," width='150' height='175' />"; ?>

I'll get an result of:

<img src="smb://10.0.0.61/Media/Muziek/Albums/Bryan" adams="" mtv="" unplugged="" [live]="" folder.jpg="" width="150" height="175">

As you can see the result has been hacked up and the retrieval is not possible. I was wondering what additional code is needed to retrieve the complete path and display the image. The correct path is:

smb://10.0.0.61/Media/Muziek/Albums/Bryan Adams/MTV Unplugged [Live]/Folder.jpg
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Danny
  • 1
  • 3
  • You did not add open `"` at this part of code `img src='`. Try: `"; ?>` – Vladimir Jan 26 '18 at 12:35
  • I would suggest doing echos in this way (much clearer): There is no need to add static html to printed variable, when this can stay in your html. Much easier to debug :) – Rauli Rajande Jan 26 '18 at 12:39

1 Answers1

1

Check your syntax here, change this..

<td><?php echo '<img src='.$row['url']," width='150' height='175' />"; ?>

To this..

<td><?php echo '<img src="'.$row['url'].'" width="150" height="175" />'; ?> </td>

Also, try removing the spaces from folder names, change it for a - or a _ instead. If you don't want to change the folder names, you can also encode them. Check this post for more info

  • I saw that the output is now correct. The image however is not there.... – Danny Jan 26 '18 at 12:45
  • Make sure the path and file format are correct, have you only changed the syntax or did you also deal with the spaces? – Leonardo Freitas Jan 26 '18 at 12:47
  • I have tried it with this additional code: Also with: '/preview="([^"]+)"/' but no luck as off yet – Danny Jan 26 '18 at 12:51
  • Since you are using php, you can just use the enconde funtcion (http://php.net/manual/en/function.urlencode.php) instead of regex.. Make sure the path is correct by right clicking the image on your web page (or where it was supposed to be) and then click "inspect element" – Leonardo Freitas Jan 26 '18 at 12:56
  • Did that and got the next result: Which is ok, but still no picture. I understand it's because of a space in it, but with other pages on the same site (Movie or Serie covers) it works and displays the image (That code returned in: ) And Yes, the first is local on a server, the second online from IMDB – Danny Jan 26 '18 at 12:59
  • I have looked for a album without spaces in name, or album name and found one. For this album no image is diplayed. the path is: When I inspect the code behind it, it only tells me the pricture couldn;t be loaded. why? (*not known) – Danny Jan 26 '18 at 14:12