PHP Parse error: syntax error, unexpected ')', expecting '&' or T_VARIABLE

Discussion in 'PHP' started by goldenbutton121284, Jul 21, 2012.

  1. #1
    Good evening!

    First of all I am a total newbie and have made a mistake that feels like the end of the world. I would just like a snippet of your wonderful wisdom to get me out of this mess lol!

    I get this error message

    PHP Parse error: syntax error, unexpected ')', expecting '&' or T_VARIABLE in \\PDC2\sites\i\impressionsweddinginvitations.co.uk\public_html\wp-content\themes\purple-pastels\functions.php on line 64

    The code

    }
    endif;
    add_action( 'after_setup_theme', 'purplepastels_theme_setup' );


    // add custom menu support
    if( function_exists( 'register_nav_menu' ) && !function_exists( 'purplepastels_register_menus' )) :
    function purplepastels_register_menus() {
    register_nav_menu( 'toptabs', __( 'Top Tabs', 'purplepastels' ) );
    }
    add_action( 'init', 'purplepastels_register_menus' );
    endif;



    ****I think it relates to the line in bold******



    I can not thank you enough in advance if you could provide me with the correct code!

    Thank you so much
    Paula


    (secretly wishing I had a stash of money to pay someone to build my site)
     
    goldenbutton121284, Jul 21, 2012 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #2
    uhm... that code makes no sense... the function declaration probably doesn't go inside the IF, that should be a "{" not a ":" at the end of that IF statement's line...

    Really though it's that colon that's messing things up. Should be a curly bracket, that isn't a SWITCH/CASE.
     
    deathshadow, Jul 21, 2012 IP
  3. Ray Baron

    Ray Baron Member

    Messages:
    148
    Likes Received:
    10
    Best Answers:
    3
    Trophy Points:
    43
    #3
    [Tried to delete my answer since it was redundant ...]
     
    Ray Baron, Jul 21, 2012 IP
  4. goldenbutton121284

    goldenbutton121284 Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hello Deathshadow!

    Thank you for replying......i made the change as suggested but this doesn't seem to have fixed the error

    The code now looks like this

    }
    endif;
    add_action( 'after_setup_theme', 'purplepastels_theme_setup' );


    // add custom menu support
    if( function_exists( 'register_nav_menu' ) && !function_exists( 'purplepastels_register_menus' )) {
    function purplepastels_register_menus() {
    register_nav_menu( 'toptabs', __( 'Top Tabs', 'purplepastels' ) );
    }
    add_action( 'init', 'purplepastels_register_menus' );
    endif;


    Anymore suggestions?

    Once again I thank you for your time in helping me!
    Kind regards
    Paula
     
    goldenbutton121284, Jul 22, 2012 IP
  5. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #5
    Uhm... why are you using endIf when you have curly brackets -- that's a OR, not a both... I think how you're even trying to form the IF statements is gibberish unless you do that weirdo <?php ?> nonsense on every blasted line or something else we're just not seeing here.

    Really your code doesn't make a whole lot of sense -- if the rest of it is anything like this, I'd be surprised to see it reach the line you're saying it's bombing on -- but again, that's why trying to diagnose problems from incomplete snippets are a nightmare.

    But again, I don't use endif in my code -- ever. That's curly brackets job.

    Some code indentation wouldn't hurt either.

    
    // add custom menu support
    if (
    	function_exists('register_nav_menu') &&
    	!function_exists('purplepastels_register_menus')
    ) {
    	function purplepastels_register_menus() {
    		register_nav_menu('toptabs',__('Top Tabs','purplepastels'));
    	}
    	add_action( 'init', 'purplepastels_register_menus' );
    }
    
    Code (markup):
    'endif' construction is just oddball -- it's why you almost never see it used on anything.

    Though I'm not sure what that __ thing is in your register_nav_menu function call... some sort of needlessly/pointlessly cryptic alias or something?

    Without seeing the whole thing it's raising more questions than I can provide answers.
     
    deathshadow, Jul 22, 2012 IP
  6. BRUm

    BRUm Well-Known Member

    Messages:
    3,086
    Likes Received:
    61
    Best Answers:
    1
    Trophy Points:
    100
    #6
    People should read and buy books on PHP before asking for questions, otherwise the forum becomes inundated with questions at every step of the way.

    Please put code in BB [ code][/code] tags.
     
    BRUm, Jul 22, 2012 IP
  7. goldenbutton121284

    goldenbutton121284 Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    All sorted thank you!
     
    goldenbutton121284, Jul 22, 2012 IP