Jump to content

HTML in PHP with PHP inside it?


lukealderton

Recommended Posts

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

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

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\">";

}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.