Syntax question

Posted on 2011-10-12
Last Modified: 2012-05-12
I have the below chunk of code. I keep getting this error:

Parse error: syntax error, unexpected '{' in /Users/app/plugins/controllers/controller.php

which is this line:
else ($coupons_sent <= 5) {

I cannot figure out what the error is for the life of me. any ideas?

if ($coupons_sent >= 5) {

			else ($sent <= 5) {
				$fetch_ids = $this->Coupon->find('list', array(
					'fields' => array('Coupon.sender_person_id'),
					'Coupon.event_id' => $this->event_id,
					'Coupon.person_id' => $person_id

				$fetch_emails = $this->Coupon->find('list', array(
					'fields' => array(''),
					'' => $fetch_ids

				$this->Session->write('sender_emails', $fetch_emails);
		$this->_response['data']['coupons_sent'] = !empty($coupons_sent) ? $coupons_sent : 0;
		if (!empty($this->data)) {

Open in new window

Question by:lvollmer
    LVL 48

    Expert Comment

    You have two curly brakets before this line when you only need one:

    $this->_response['data']['coupons_sent'] = !empty($coupons_sent) ? $coupons_sent : 0;
    LVL 19

    Accepted Solution

    do you mean for this ($sent <= 5) to be part of the code, or a comment, if it's part of the code then I think you need an *IF*

    as a comment
    else { // ($coupons_sent < 5)

    as an if

    else if ($sent <= 5) {

    Author Comment

    it's part of the code. i will try both solutions and report back thanks

    Author Closing Comment

    else if was the problem thanks!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Easy Project Management (No User Manual Required)

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
    These days socially coordinated efforts have turned into a critical requirement for enterprises.
    Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now