Using an a href with php code

<?php
    $id = 5;
    session_start();
    function fn1(){
		//code
		return "http://www.philosophaie.heliohost.org/Julian_Date.php?"&data=$id";
    }
    session_write_close();
?>


<a href = "<?php echo fn1(); ?>">Text</a>

The a href does not work and I keep getting:

%34http://www.philosophaie.heliohost.org/Julian_Date.php?"&data=5

on the link mouseover. How do I remove the %34 to execute the link?

The end of your string is the problem, see the below which I’ve highlighted in red to show the problem.

Julian_Date.php?[COLOR=#ff0000]"&[/COLOR]data=$id";

There is no reason to have the double quotes there as well as the ampersand after the double quote as your creating an improperly formatted URL, if you need to at any point use symbols and such in a URL you need to use the urlencode() function.

It was really:

return “http://www.philosophaie.heliohost.org/Julian_Date.php?sec=$urladd"."&data=$id”;

and I still got the %34 error.

Hi,
You have to pass the $id to the function, because is defined outside the function. Try this code:

<?php
$id = 5;
session_start();
function fn1($id){
  //code
  return "http://www.philosophaie.heliohost.org/Julian_Date.php?&data=$id";
}
session_write_close();
?>

<a href = "<?php echo fn1($id); ?>">Text</a>