<?php
  // find out the domain:
  $domain = $_SERVER['HTTP_HOST'];
  // find out the path to the current file:
  $path = $_SERVER['SCRIPT_NAME'];
  // find out the QueryString:
  $queryString = $_SERVER['QUERY_STRING'];
  // put it all together:
  $url = "http://" . $domain . $path . "?" . $queryString;
  echo "The current URL is: " . $url . "<br />";
if ( $url == "http://www.xxx.com/yyy" ) {
	echo "Your name is someguy!<br />";
}
?>

While using this above code, the string "Your name is someguy" is displayed in that particular page exactly. But when I use the following java script :

<script src="http://www.cpalead.com/mygateway.php?pub=9868&gateid=MTk1MA%3D%3D" language="JavaScript" type="text/javascript"></script>

instead of
echo "Your name is someguy!<br />" like this :

<?php
  // find out the domain:
  $domain = $_SERVER['HTTP_HOST'];
  // find out the path to the current file:
  $path = $_SERVER['SCRIPT_NAME'];
  // find out the QueryString:
  $queryString = $_SERVER['QUERY_STRING'];
  // put it all together:
  $url = "http://" . $domain . $path . "?" . $queryString;
  echo "The current URL is: " . $url . "<br />";
if ( $url == "http://www.xxx.com/yyy" ) {
	<script src="http://www.cpalead.com/mygateway.php?pub=9868&gateid=MTk1MA%3D%3D" language="JavaScript" type="text/javascript"></script>";
}
?>

Parse error: syntax error, unexpected '<' in /home/xxxxx/public_html/xxx.com/rt_includes.php on line 21

i am inserting that code in rt_includes.php

Please help me to solve this.

<?php
  // find out the domain:
  $domain = $_SERVER['HTTP_HOST'];
  // find out the path to the current file:
  $path = $_SERVER['SCRIPT_NAME'];
  // find out the QueryString:
  $queryString = $_SERVER['QUERY_STRING'];
  // put it all together:
  $url = "http://" . $domain . $path . "?" . $queryString;
  echo "The current URL is: " . $url . "<br />";
if ( $url == "http://www.xxx.com/yyy" ) {
	echo '<script src="http://www.cpalead.com/mygateway.php?pub=9868&gateid=MTk1MA%3D%3D" language="JavaScript" type="text/javascript"></script>';
}
?>

If you look at line 21, you will see the problem yourself.

<script src=....

should be echoed.

hi nav33n, thank you very much for your help. Now its working like charm. Thanks again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.