Jump to content

Help with Parse error: syntax error


shmideo

Recommended Posts

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

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

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

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.