Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Integrating PHP with Databases Querying the Database with PHP Integrating Database Results

Daniel Schroeder
Daniel Schroeder
13,859 Points

Star Wars: The Ultimate Soundtrack image not displaying when using database instead of original catalog array

NOTE I'm using MySQL on my own local machine, not the treehouse workspaces, so this may not apply to you if you are not using the downloaded program files.

Hi all, once I switched from the associative array that was hard-coded in data.php to the associative array returned by the PDO in connection.php, the Star Wars: The Ultimate Soundtrack image was broken and did not display.

The problem seems to be this line in database.sql: INSERT INTO Media VALUES (29,'Star Wars: The Ultimate Soundtrack Collection','img/media/soundtrack_star_wars',54,'CD',2016,'Music');

The path 'img/media/soundtrack_star_wars' should have .jpg appended to it, like so: INSERT INTO Media VALUES (29,'Star Wars: The Ultimate Soundtrack Collection','img/media/soundtrack_star_wars.jpg',54,'CD',2016,'Music');

If using a local MySQL db, perform the following query and this will be updated:

UPDATE Media SET img='img/media/soundtrack_star_wars.jpg' WHERE media_id=29;

Hope that helps!

Brian Pedigo
Brian Pedigo
25,712 Points

Thanks so much for this post! I am doing this course on my local machine too and noticed the error as well. I was pondering how to correct it when I came across this! Cheers to you for doing "all the work" ! XD

1 Answer

The image in the media table is missing .jpg You can fix this with with a SQL update statement.

UPDATE media
SET img = 'img/media/soundtrack_star_wars.jpg'
WHERE media_id = 29;