News:

Wondering if this will always be free?  See why free is better.

Main Menu

Parse error

Started by tmlfever, August 17, 2015, 01:01:52 PM

Previous topic - Next topic

tmlfever


Can anyonr tell me why I'm getting a parse error with this code. Thanks in advance for help.

<span class='st_facebook' displayText='Facebook'></span>
<span class='st_twitter' displayText='Tweet'></span>
<span class='st_linkedin' displayText='LinkedIn'></span>
<span class='st_googleplus' displayText='Google +'></span>
<span class='st_pinterest' displayText='Pinterest'></span>
<span class='st_blogger' displayText='Blogger'></span>
<span class='st_sharethis' displayText='ShareThis'></span>
<span class='st_email' displayText='Email'></span>


"Every time you wake up, ask yourself, "What good am I going to do today?", remember that when the sun goes down at sunset, it will take a part of your life with it."

I've seen the Leaf jersey everywhere from Kabul to Tonga. I've never seen it in a Stanley Cup final.

Livaco

Could you show the error??

Kindred

What are you doing with that code?


If you are just pasting that into your template file, then you have a definite issue, since that is HTML and would need to be parsed into a php echo statement, including escaped single quotes....
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

tmlfever



"Every time you wake up, ask yourself, "What good am I going to do today?", remember that when the sun goes down at sunset, it will take a part of your life with it."

I've seen the Leaf jersey everywhere from Kabul to Tonga. I've never seen it in a Stanley Cup final.

S_EEk_ER

Quote from: Livaco on August 17, 2015, 01:02:47 PM
Could you show the error??

We are trying to add the ShareThis button as a link on our page.  It's a two part process, we have to copy some Javascript into the header - done and no parse errors.

The second instructions they gave us are "Copy the span tags and place them where you want your buttons to appear in the code.
(This style is the most adaptable to any type of page design. We strongly recommend that you place them towards top of the page.)"



This is the error...

Template Parse Error!
There was a problem loading the /Themes/blu/index.template.php template or language file. Please check the syntax and try again - remember, single quotes (') often have to be escaped with a slash (\). To see more specific error information from PHP, try accessing the file directly.

You may want to try to refresh this page or use the default theme.
syntax error, unexpected '/' (T_NS_SEPARATOR), expecting ',' or ';'

Kindred

Quote from: Kindred on August 17, 2015, 01:09:35 PM
If you are just pasting that into your template file, then you have a definite issue, since that is HTML and would need to be parsed into a php echo statement, including escaped single quotes....
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

S_EEk_ER

Actually, let me clarify because I don't think the Javascript piece is working.  This is what we have to do, along with the only instructions we were given.


Copy the span tags and place them where you want your buttons to appear in the code.
(This style is the most adaptable to any type of page design. We strongly recommend that you place them towards top of the page.)



<span class='st_twitter' displayText='Tweet'></span>
<span class='st_reddit' displayText='Reddit'></span>
<span class='st_pinterest' displayText='Pinterest'></span>
<span class='st_facebook' displayText='Facebook'></span>
<span class='st_googleplus' displayText='Google +'></span>
<span class='st_flipboard' displayText='Flipboard'></span>
<span class='st_delicious' displayText='Delicious'></span>
<span class='st_digg' displayText='Digg'></span>
<span class='st_tumblr' displayText='Tumblr'></span>
<span class='st_blogger' displayText='Blogger'></span>
<span class='st_wordpress' displayText='WordPress'></span>
<span class='st_myspace' displayText='MySpace'></span>
<span class='st_stumbleupon' displayText='StumbleUpon'></span>
<span class='st_pocket' displayText='Pocket'></span>
<span class='st_whatsapp' displayText='WhatsApp'></span>
<span class='st_evernote' displayText='Evernote'></span>
<span class='st_email' displayText='Email'></span>
<span class='st_sharethis' displayText='ShareThis'></span>




Copy the script tags and place them inside and at the end of your "head" tag.


<script type="text/javascript">var switchTo5x=true;</script>
<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
<script type="text/javascript">stLight.options({publisher: "4fd4d8a2-8234-49ee-b645-b1a4207df4b7", doNotHash: false, doNotCopy: false, hashAddressBar: false});</script>

S_EEk_ER

Quote from: Kindred on August 17, 2015, 05:29:04 PM
Quote from: Kindred on August 17, 2015, 01:09:35 PM
If you are just pasting that into your template file, then you have a definite issue, since that is HTML and would need to be parsed into a php echo statement, including escaped single quotes....

If I understand you correctly, every single quote has to be \' instead, correct?  I tried this code, same parse error.


<span class='\st_twitter'\ displayText='\Tweet'\></span>
<span class='\st_reddit'\ displayText='\Reddit'\></span>
<span class='\st_pinterest'\ displayText='\Pinterest'\></span>
<span class='\st_facebook'\ displayText='\Facebook'\></span>
<span class='\st_googleplus'\ displayText='\Google +'\></span>
<span class='\st_flipboard'\ displayText='\Flipboard'\></span>
<span class='\st_delicious'\ displayText='\Delicious'\></span>
<span class='\st_digg'\ displayText='\Digg'\></span>
<span class='\st_tumblr'\ displayText='\Tumblr'\></span>
<span class='\st_blogger'\ displayText='\Blogger'\></span>
<span class='\st_wordpress'\ displayText='\WordPress'\></span>
<span class='\st_myspace'\ displayText='\MySpace'\></span>
<span class='\st_stumbleupon'\ displayText='\StumbleUpon'\></span>
<span class='\st_pocket'\ displayText='\Pocket'\></span>
<span class='\st_whatsapp'\ displayText='\WhatsApp'\></span>
<span class='\st_evernote'\ displayText='\Evernote'\></span>
<span class='\st_email'\ displayText='\Email'\></span>
<span class='\st_sharethis'\ displayText='\ShareThis'\></span>

Kindred

I repeat, yet again....

Quote from: Kindred on August 17, 2015, 05:29:04 PM
Quote from: Kindred on August 17, 2015, 01:09:35 PM
If you are just pasting that into your template file, then you have a definite issue, since that is HTML and would need to be parsed into a php echo statement, including escaped single quotes....

not only do they have to be escaped, but the code MUST be inside an echo statement.

You can not just put code randomly into the template.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

S_EEk_ER

Quote from: Kindred on August 17, 2015, 05:32:17 PM
I repeat, yet again....

Quote from: Kindred on August 17, 2015, 05:29:04 PM
Quote from: Kindred on August 17, 2015, 01:09:35 PM
If you are just pasting that into your template file, then you have a definite issue, since that is HTML and would need to be parsed into a php echo statement, including escaped single quotes....

not only do they have to be escaped, but the code MUST be inside an echo statement.

You can not just put code randomly into the template.

Okay, I will see if I can figure out how to do that.  I don't know how to code in PHP at all, so I'll see what I can find based on what you said.  Thank-you.

Kindred

oh... and I just noticed.... you have the / in the wrong location.   escaping a character means that / must come BEFORE the character
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

JBlaze

<span class="st_twitter" displayText="Tweet"></span>
<span class="st_reddit" displayText="Reddit"></span>
<span class="st_pinterest" displayText="Pinterest"></span>
<span class="st_facebook" displayText="Facebook"></span>
<span class="st_googleplus" displayText="Google +"></span>
<span class="st_flipboard" displayText="Flipboard"></span>
<span class="st_delicious" displayText="Delicious"></span>
<span class="st_digg" displayText="Digg"></span>
<span class="st_tumblr" displayText="Tumblr"></span>
<span class="st_blogger" displayText="Blogger"></span>
<span class="st_wordpress" displayText="WordPress"></span>
<span class="st_myspace" displayText="MySpace"></span>
<span class="st_stumbleupon" displayText="StumbleUpon"></span>
<span class="st_pocket" displayText="Pocket"></span>
<span class="st_whatsapp" displayText="WhatsApp"></span>
<span class="st_evernote" displayText="Evernote"></span>
<span class="st_email" displayText="Email"></span>
<span class="st_sharethis" displayText="ShareThis"></span>


Hopefully, you're adding this to an already existing echo statement. If not, create one.

<?php
echo '<span class="st_twitter" displayText="Tweet"></span>
<span class="st_reddit" displayText="Reddit"></span>
<span class="st_pinterest" displayText="Pinterest"></span>
<span class="st_facebook" displayText="Facebook"></span>
<span class="st_googleplus" displayText="Google +"></span>
<span class="st_flipboard" displayText="Flipboard"></span>
<span class="st_delicious" displayText="Delicious"></span>
<span class="st_digg" displayText="Digg"></span>
<span class="st_tumblr" displayText="Tumblr"></span>
<span class="st_blogger" displayText="Blogger"></span>
<span class="st_wordpress" displayText="WordPress"></span>
<span class="st_myspace" displayText="MySpace"></span>
<span class="st_stumbleupon" displayText="StumbleUpon"></span>
<span class="st_pocket" displayText="Pocket"></span>
<span class="st_whatsapp" displayText="WhatsApp"></span>
<span class="st_evernote" displayText="Evernote"></span>
<span class="st_email" displayText="Email"></span>
<span class="st_sharethis" displayText="ShareThis"></span>'
;


Also, you can use double quotes in this instance since you're still using HTML.
Jason Clemons
Former Team Member 2009 - 2012

S_EEk_ER

zilladotexe, we used the double quotes code using HTML and got it to work.  Really appreciate it, thank-you.

I'm trying to wrap my head around PHP because unlike other languages, it seems like you can code in PHP, HTML and perhaps other languages as well.  So I'm often trying to figure out what language I should write my code in when in a PHP page.  Is there a preferred or recommended language when you have the choice?

Regarding the echo ' code you'll see throughout PHP script, I was under the impression this was just a print statement.  And I didn't realize there was also a single closing ' at the end of the statement.

Do I have this right in saying a echo ' is the beginning of a wrapper for code to be placed within it which you develop, then that script gets executed on the database at the server level?  This might be a light-bulb moment for me an explains why PHP is considered a server-side scripting language...

JBlaze

To better understand PHP functions, you should read the PHP manual. :)

http://php.net/echo
Jason Clemons
Former Team Member 2009 - 2012

S_EEk_ER

Quote from: zilladotexe on August 17, 2015, 09:18:13 PM
To better understand PHP functions, you should read the PHP manual. :)

http://php.net/echo

Manual page bookmarked and saved.  Good reference, thanks!

Advertisement: