Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

re: if logic in function

Posted on 2009-04-08
5
Medium Priority
?
262 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

604 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