Stop & turning in to & – solution

Recently I had to solve a painful problem using PHP and Javascript.

I discovered that trying to pass, or create a URL with &val=val was becoming &=val and couldn’t find a way to fix it.
As I was implementing the script in to a Joomla site, it was becoming automatic. Without the Joomla integration, it worked ok. It was very strange, but I have now found the solution.

This was how I solved the problem, using substring(0,1).
Here’s an example of how to maybe use this code.
function callAJAX()
        var var_Date = document.getElementById('DateAJAX').value;    
        var l2 = '&type=' + <?php echo $type; ?>; 
        var l2=l2.substring(0,1) + '<?php echo "type="  . $type; ?>';  // stupid js fix 
        jsfunction('ajaxdiv', 'phpfilename.php?date=' +var_Date + l2,'<? echo $num; ?>'); 

The URL will result in something like this:



I hope this helps all the other geeky boffins out there .


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at

Up ↑

%d bloggers like this: