?
Solved

re: if logic in function

Posted on 2009-04-08
5
Medium Priority
?
261 Views
Last Modified: 2012-05-06
i'm not sure where i'm going wrong here

I'm getting this error:
Parse error: syntax error, unexpected T_IF, expecting ';' or '{' in /home/cjehost/public_html/collectors_moment/libraries/joomla/html/html/behavior.php on line 63

thanks!
function caption() 
		if ($_GET['Itemid']=="54"){
			JHTML::script('caption2.js');
		}; else {
			JHTML::script('caption.js');
		};

Open in new window

0
Comment
Question by:phillystyle123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 19

Accepted Solution

by:
Michael701 earned 1000 total points
ID: 24101662
try these
// this should work
 
function caption() 
{
                if ($_GET['Itemid']=="54"){
                        JHTML::script('caption2.js');
                } else {
                        JHTML::script('caption.js');
                };
}
 
 
// this also should work
 
function caption() 
{
                if ($_GET['Itemid']=="54")
                        JHTML::script('caption2.js');
                else
                        JHTML::script('caption.js');
                
}

Open in new window

0
 
LVL 10

Expert Comment

by:Phatzer
ID: 24101722
               }; else {

Indeed, get rid of that cheeky ';'
0
 
LVL 10

Expert Comment

by:Phatzer
ID: 24101731
Sorry, you don't need to have a ';' on closing brackets...
                if ($_GET['Itemid']=="54"){
                        JHTML::script('caption2.js');
                }; else {
                        JHTML::script('caption.js');
                };
 
Should be:
 
                if ($_GET['Itemid']=="54"){
                        JHTML::script('caption2.js');
                } else {
                        JHTML::script('caption.js');
                }

Open in new window

0
 
LVL 10

Expert Comment

by:Phatzer
ID: 24101752
Or... sorry for the repost:

I noticed that you hadn't got the 'caption() {' in your code, you just had 'caption()'
function caption() {
                if ($_GET['Itemid']=="54"){
                        JHTML::script('caption2.js');
                } else {
                        JHTML::script('caption.js');
                }

Open in new window

0
 

Author Closing Comment

by:phillystyle123
ID: 31568253
Thanks Michael701 - this seemed like the most elegant solution:

function caption()
{
                if ($_GET['Itemid']=="54")
                        JHTML::script('caption2.js');
                else
                        JHTML::script('caption.js');
               
}

aside from using too many ';' s - what was i doing wrong?
0

Featured Post

WordPress Tutorial 2: Terminology

An important part of learning any new piece of software is understanding the terminology it uses. Thankfully WordPress uses fairly simple names for everything that make it easy to start using the software.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question