lukealderton Posted April 29, 2010 Share Posted April 29, 2010 Hello, This is my first post on this website so sorry in advance for anything I do or don't do. I'm trying to add a url using php, I have the paths set up in config.php and they are as following: // Filedirs $filedir_mappers_avatars = "images/mappers/avatars/original/"; $filedir_mappers_avatars_icon = "images/mappers/avatars/icons/"; $filedir_maps = "images/maps/original/"; $filedir_maps_icon = "images/maps/icons/"; $filedir_maps_games = "images/maps/games/"; The file paths obviously go to folders where images are located, but when I add it all together in a page as seen below, it shows me an "internal server error" (500) Can anyone help me find the problem with he below piece of code? I would be very great-full, Thanks in advance. <?php if(file_exists($filedir_maps.$map_cat_name"/"$map_id".jpg") == true) { echo "<a href=\""$filedir_maps.$map_cat_name"/"$map_id".jpg\" rel=\"lightbox\"><img height=\"315\" src=\""$filedir_maps.$map_cat_name"/"$map_id".jpg\" width=\"520\"></a>"; } else { echo "<img height=\"315\" src=\"images/template/errors/missing_map_image.png\" width=\"520\">"; } ?> Link to comment https://forums.phpfreaks.com/topic/200198-html-in-php-with-php-inside-it/ Share on other sites More sharing options...
Ken2k7 Posted April 29, 2010 Share Posted April 29, 2010 The error I see is that you messed up string concatenation in a few places. Though, I don't know why that would throw a 500 error. Also, read the rules about proper ways to post code. There's a link in the red text that displays before you post. Link to comment https://forums.phpfreaks.com/topic/200198-html-in-php-with-php-inside-it/#findComment-1050692 Share on other sites More sharing options...
teamatomic Posted April 29, 2010 Share Posted April 29, 2010 Its your quotes. Whats with the double double quotes? \"" echo "<a href=\"domain.com\"><img src=\"image.gif\"></a>"; also, inside a double quoted echo you dont need to use a dot. echo "$this$that$everything"; will do just fine HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/200198-html-in-php-with-php-inside-it/#findComment-1050751 Share on other sites More sharing options...
lukealderton Posted April 30, 2010 Author Share Posted April 30, 2010 Thanks for the help guys, I managed to fix the code, and the page works fine, if you wanted to see the code now its working, ill post it below: <?php if(file_exists($filedir_maps.$map_cat_name."/".$map_id.".jpg") == true) { echo "<a href=\"".$filedir_maps.$map_cat_name."/".$map_id.".jpg\" rel=\"lightbox\"><img height=\"315\" src=\"".$filedir_maps.$map_cat_name."/".$map_id.".jpg\" width=\"520\"></a>"; } else { echo "<img height=\"315\" src=\"images/template/errors/missing_map_image.png\" width=\"520\">"; } ?> Link to comment https://forums.phpfreaks.com/topic/200198-html-in-php-with-php-inside-it/#findComment-1050802 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.