Jump to content

Trying to post javascript in a php script getting error


the-sexy-slug

Recommended Posts

Hello

 

I am trying to post a javascript code an example would be adsense into a php script and all I am getting is this error:-

 

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/usermane/public_html/webaddress.co.uk/test/test.php on line 2

 

This is my very simple script:

 

<?php  
  echo "<script language="JavaScript" src=""></script>"; 
   ?>  

 

I have not posted the full script as it is a affiliate link script.

 

Thanks in advance

Hello

 

I am trying to post a javascript code an example would be adsense into a php script and all I am getting is this error:-

 

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/usermane/public_html/webaddress.co.uk/test/test.php on line 2

 

This is my very simple script:

 

<?php  
  echo "<script language="JavaScript" src=""></script>"; 
   ?>  

 

I have not posted the full script as it is a affiliate link script.

 

Thanks in advance

 

The problem is with your quotes.  You can't use double quotes to both denote a string and have double quoted text within the string.  You need to do one of two things:

 

1. Mix in single quotes

2. Escape the double quotes within the string

 

So...

 

1.

echo '<script language="Javascript" src=""></script>';

 

2.

echo "<script language=\"Javascript\" src=\"\"></script>";

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.