-1

how to fix this syntax error,

unexpected 'have' (T_STRING) in /home/mithraa/public_html/svirtzone.com/projects/fandc/app/code/core/Mage/Newsletter/controllers/SubscriberController.php

public function unsubscribecusAction()
{
    $email = $this->getRequest()->getParam(’email’);
    $subsModel = Mage::getModel(’newsletter/subscriber’);
    $subscriber = $subsModel->loadByEmail($email);

    $id = (int) $subsModel->getId();
    $code = (string) $subsModel->getCode();
    if ($id && $code) {
        $session = Mage::getSingleton(’core/session’);
        try {
               Mage::getModel(’newsletter/subscriber’)->load($id)->setCheckCode($code)->unsubscribe();
               $session->addSuccess($this->__(’You have been unsubscribed.’));
        }
        catch (Mage_Core_Exception $e) {
            $session->addException($e, $e->getMessage());
        }
        catch (Exception $e) {
            $session->addException($e, $this->__(’There was a problem with the un-subscription.’));
        }
     }
     $this->_redirectReferer();
  } 
RiggsFolly
  • 93,638
  • 21
  • 103
  • 149

4 Answers4

1

You use the wrong quotation mark characters to declare strings:

Correct:

'hello', "hello"

Wrong:

’hello’
Nana Partykar
  • 10,556
  • 10
  • 48
  • 77
Daniel Müller
  • 426
  • 1
  • 5
  • 19
0

Change (Quotation Marks) to '

    public function unsubscribecusAction()
    {
      $email = $this->getRequest()->getParam('email');
      $subsModel = Mage::getModel('newsletter/subscriber');
      $subscriber = $subsModel->loadByEmail($email);

      $id = (int) $subsModel->getId();
      $code = (string) $subsModel->getCode();
        if ($id && $code) {
       $session = Mage::getSingleton('core/session');
        try {
        Mage::getModel('newsletter/subscriber')->load($id)->setCheckCode($code)->unsubscribe();
        $session->addSuccess($this->__('You have been unsubscribed.'));
        }
        catch (Mage_Core_Exception $e) {
              $session->addException($e, $e->getMessage());
        }
            catch (Exception $e) {
                 $session->addException($e, $this->__('There was a problem with the un-subscription.'));
            }
        }
        $this->_redirectReferer();
    }
Nana Partykar
  • 10,556
  • 10
  • 48
  • 77
0

in your code you using tiled sign sign instead of use single ' OR " for everywhere in your code. like as

’email’ replace with 'email' OR "email"

Nana Partykar
  • 10,556
  • 10
  • 48
  • 77
Shailesh Katarmal
  • 2,757
  • 1
  • 12
  • 15
0

I suspect the issue is the difference between the and ' character. See if this works;

public function unsubscribecusAction() {
    $email = $this->getRequest()->getParam('email');
    $subsModel = Mage::getModel('newsletter/subscriber');
    $subscriber = $subsModel->loadByEmail($email);

    $id = (int) $subsModel->getId();
    $code = (string) $subsModel->getCode();
    if ($id && $code) {
        $session = Mage::getSingleton('core/session');
        try {
            Mage::getModel('newsletter/subscriber')->load($id)->setCheckCode($code)->unsubscribe();
            $session->addSuccess($this->__('You have been unsubscribed.'));
        } catch (Mage_Core_Exception $e) {
            $session->addException($e, $e->getMessage());
        } catch (Exception $e) {
            $session->addException($e, $this->__('There was a problem with the un-subscription.'));
        }
    }
    $this->_redirectReferer();
}
Benjy1996
  • 159
  • 7