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

Link to comment
Share on other sites

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

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.