shmideo Posted November 15, 2013 Share Posted November 15, 2013 Hi guys Trying to modify code to add an href but the syntaxt is wrong. Getting Parse error is on the last line, $banner_location. I think it's to do with the <>, but not sure. Ttried variations but keeps erroring, hope someone can help. Thanks! <?php$pageURL = $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];if(preg_match("~/de/~",$pageURL)){$page_language = "de";}elseif(preg_match("~/en/~",$pageURL)){$page_language = "en";}else{$page_language ="dk";}$banner_location = "http://".$_SERVER['SERVER_NAME']."/images/".$page_language.".png" <a href="http://".$_SERVER['SERVER_NAME']."/tilfredshedsgaranti-".$page_language.;</a>?> Link to comment https://forums.phpfreaks.com/topic/283944-help-with-parse-error-syntax-error/ Share on other sites More sharing options...
dalecosp Posted November 15, 2013 Share Posted November 15, 2013 Yup it's wrong. Since I'm not sure what you want, dunno if I can fix it. Does this work? $banner_location = "http://".$_SERVER['SERVER_NAME']."/images/".$page_language.".png"; echo "<a href=http://".$_SERVER['SERVER_NAME']."/tilfredshedsgaranti-".$page_language.">"; echo "Link text goes here"; echo "</a>"; Link to comment https://forums.phpfreaks.com/topic/283944-help-with-parse-error-syntax-error/#findComment-1458458 Share on other sites More sharing options...
denno020 Posted November 16, 2013 Share Posted November 16, 2013 You don't close the opening <a> tag with the '>' symbol $banner_location = "http://".$_SERVER['SERVER_NAME']."/images/".$page_language.".png" <a href="http://".$_SERVER['SERVER_NAME']."/tilfredshedsgaranti-".$page_language.;</a> should be (also note that the image was moved inside the <a> tags, and into an <img> tag). $banner_location = "<a href=\"http://".$_SERVER['SERVER_NAME']."/tilfredshedsgaranti-".$page_language."><img src=\"http://".$_SERVER['SERVER_NAME']."/images/".$page_language.".png\"/></a>"; //Or with single quotes so you don't have to escape the double quotes: $banner_location = '<a href="http://'.$_SERVER['SERVER_NAME'].'/tilfredshedsgaranti-'.$page_language.'><img src="http://'.$_SERVER['SERVER_NAME'].'/images/'.$page_language.'.png"/></a>'; This is making an assumption as to what you want. Hope that helps Denno Link to comment https://forums.phpfreaks.com/topic/283944-help-with-parse-error-syntax-error/#findComment-1458493 Share on other sites More sharing options...
shmideo Posted November 16, 2013 Author Share Posted November 16, 2013 Thank you so much guys! Shmideo Link to comment https://forums.phpfreaks.com/topic/283944-help-with-parse-error-syntax-error/#findComment-1458579 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.