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

Link to comment
Share on other sites

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

Edited by denno020
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.