New Server

I have changed my webhost server and now i have this error i dont know why.

Parse error: syntax error, unexpected T_STRING in /home/stylesto/public_html/protected/controllers/SiteController.php on line 1

And what is on the first line of that file (SiteController) ?

What’s the first line of that file?

Edit: ninja’d

<?php

:)

can you paste your lines up to the declaration of the class

Can you provide the file as an attachment? Just to confirm that there are no hidden characters or anything.

Which OS are the old and new servers running and which OS do you develop on?

The OS i am developing is windows,the host is linux.

My controller and mu index.php:

index


<?php


// change the following paths if necessary

$yii=dirname(__FILE__).'/framework/yii.php';

$config=dirname(__FILE__).'/protected/config/main.php';







// remove the following lines when in production mode

defined('YII_DEBUG') or define('YII_DEBUG',true);

// specify how many levels of call stack should be shown in each log message

defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);


require_once($yii);

Yii::createWebApplication($config)->run();

?>

controller:


<?php


class SiteController extends Controller 


{    


public function init() {        


$app = Yii::app();        


if (isset($app->session['lg'])) {            $app->language = $app->session['lg'];        }    }    public function actionLanguage() {        $app = Yii::app();        if (isset($_GET['lg'])) {            $app->session['lg'] = $_GET['lg'];        }        $this->redirect('index');    }    public function actionFinalizar() {        Yii::import('ext.yii-mail.YiiMailMessage');        Yii::import('application.modules.admin.models.*');        if (isset(Yii::app()->session['encomenda'])) {            $encomenda = Encomenda::model()->findByPk(Yii::app()->session['encomenda']);            $encomenda->confirmed = true;            $encomenda->save();            $lista = '';            foreach ($encomenda->encomendaLinhas as $encomendaLinha) :                $lista = $lista . $encomendaLinha->ritmo->artist . ' - ' . $encomendaLinha->ritmo->title . '<br>';            endforeach;            $message = new YiiMailMessage;            $message->setBody('<h1>StyleStore</h1>O utilizador ' . $encomenda->cliente->nome . '                           com o email '.$encomenda->cliente->email.' encomendou os seguintes ritmos:<br><br>' . $lista, 'text/html');            $message->setTo(Yii::app()->params['adminEmail']);            $message->subject = 'Encomenda de Ritmos';            $message->from = Yii::app()->params['adminEmail'];            Yii::app()->mail->send($message);            Yii::app()->user->setFlash('success', Yii::t('app', 'Style(s) bought with success.Wait for a confirmation email'));            Yii::app()->session->add('encomenda', null);        }        $this->redirect('index');    }    public function actions() {        return array(            // captcha action renders the CAPTCHA image displayed on the contact page            'captcha' => array(                'class' => 'CCaptchaAction',                'backColor' => 0xFFFFFF,            ),            // page action renders "static" pages stored under 'protected/views/site/pages'            // They can be accessed via: index.php?r=site/page&view=FileName            'page' => array(                'class' => 'CViewAction',            ),        );    }           public function actionIndex() {        Yii::import('application.modules.admin.models.*');        $topten = false;        if (isset($_GET['topten'])) {            $topten=true;        }        if (isset($_GET['song'])) {            if ($_GET['song'] != '') {                Yii::app()->session->add('song', $_GET['song']);            } else {                unset(Yii::app()->session['song']);            }        }        if (isset($_POST['teclado'])) {            Yii::app()->session->add('teclado', $_POST['teclado']);        }        if (isset($_GET['letra'])) {            Yii::app()->session->add('letra', $_GET['letra']);        }        if (isset($_GET['categoria'])) {            Yii::app()->session->add('categoria', $_GET['categoria']);        }        $encomenda = new Encomenda;        if (isset($_GET['idritmo'])) {                        $encomendas = Yii::app()->db->createCommand('select *                                                                   from encomenda_linha                                                                  inner join encomenda on (encomenda_linha.encomenda=encomenda.idencomenda)                                                                  where style='.$_GET['idritmo'].                                                                  ' and encomenda.customer='.Yii::app()->user->id);                                               $existeEncomenda= $encomendas->query();                if ($existeEncomenda->rowCount>0) {                    Yii::app()->user->setFlash('error', Yii::t('app', 'You already order this style'));                    $this->redirect('index');                }            $ritmo = Ritmo::model()->findByPk($_GET['idritmo']);            if (!isset(Yii::app()->session['encomenda'])) {                $encomenda->createDate = date('Y-m-d H:i:s', time());                $encomenda->totalValue = $ritmo->price;                $encomenda->customer = Yii::app()->user->id;                $encomenda->quantity = 1;            } else {                                                $encomenda = Encomenda::model()->findByPk(Yii::app()->session['encomenda']);                $encomenda->quantity = $encomenda->quantity + 1;                $encomenda->totalValue = $encomenda->totalValue + $ritmo->price;            }            $encomenda->save();            $encomendaLinha = new EncomendaLinha;            $encomendaLinha->style = $_GET['idritmo'];            $encomendaLinha->encomenda = $encomenda->idencomenda;            $encomendaLinha->save();            Yii::app()->user->setFlash('success', Yii::t('app', 'Style') . ' ' . $ritmo->artist . ' - ' . $ritmo->title . ' ' . Yii::t('app', 'added with success.'));        }        if (!isset(Yii::app()->session['encomenda'])) {            Yii::app()->session->add('encomenda', $encomenda->idencomenda);        } else {            $encomenda = Encomenda::model()->findByPk(Yii::app()->session['encomenda']);        }        $cat = new CDbCriteria();        $cat->select = "*";        $cat->order = "name ASC";        $ritmos = new CDbCriteria();        $ritmos->select = "*";        $ritmos->alias = "r";        $ritmos->join = "inner join ritmo_teclado on (r.idritmo=ritmo_teclado.idritmo)";        if (isset(Yii::app()->session['song'])) {            $ritmos->addCondition("r.title like '%" . Yii::app()->session['song'] . "%'");        }        if (isset(Yii::app()->session['teclado'])) {            $ritmos->condition = "idteclado=" . Yii::app()->session['teclado'];            $teclado = Teclado::model()->findByPk(Yii::app()->session['teclado']);        } else {            $firstRecord = Yii::app()->db->createCommand('SELECT * FROM teclado')->queryScalar();            $ritmos->addCondition("idteclado=" . $firstRecord);            $teclado = Teclado::model()->findByPk(1);        }        if (isset(Yii::app()->session['letra']) && Yii::app()->session['letra'] != '0')            $ritmos->addCondition("artist like '" . Yii::app()->session['letra'] . "%'");        if (isset(Yii::app()->session['categoria'])) {            if (Yii::app()->session['categoria'] != 0)                $ritmos->addCondition("categoria=" . Yii::app()->session['categoria']);        }        $ritmos->order = "artist ASC";        if (!Yii::app()->request->isAjaxRequest) {                 $this->render('index', array('categorias' => Categoria::model()->findAll($cat),                'ritmos' => Ritmo::model()->findAll($ritmos),                'encomenda' => $encomenda,                'teclado' => $teclado,                'topten'=>$topten));        } else {            $this->renderPartial('_listaritmos', array('ritmos' => Ritmo::model()->findAll($ritmos)));        }    }    /**     * This is the action to handle external exceptions.     */    public function actionError() {        if ($error = Yii::app()->errorHandler->error) {            if (Yii::app()->request->isAjaxRequest)                echo $error['message'];            else                $this->render('error', $error);        }    }    /**     * Displays the contact page     */    public function actionContact() {        $model = new ContactForm;        Yii::import('ext.yii-mail.YiiMailMessage');        if (isset($_POST['ContactForm'])) {            $model->attributes = $_POST['ContactForm'];            if ($model->validate()) {                $message = new YiiMailMessage;                $message->setBody($model->name . ' com o email ' . $model->email . ' mandou a seguinte mensagem com o assunto "' . $model->subject . '" :' . $model->body);                $message->setTo(Yii::app()->params['adminEmail']);                $message->from = Yii::app()->params['adminEmail'];                $message->subject = 'Contacto de Utilizador';                Yii::app()->mail->send($message);                Yii::app()->user->setFlash('success', Yii::t('app', 'Thank you for contacting us. We will respond to you as soon as possible.'));                $this->redirect(Yii::app()->homeUrl);            }        }        $this->render('contact', array('model' => $model));    }    public function actionLogin() {        $model = new LoginForm;        // if it is ajax validation request        if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {            echo CActiveForm::validate($model);            Yii::app()->end();        }        if (isset($_POST['LoginForm'])) {            $model->attributes = $_POST['LoginForm'];            if ($model->validate() && $model->login())                $this->redirect(Yii::app()->user->returnUrl);        }        $this->render('login', array('model' => $model));    }    /**     * Logs out the current user and redirect to homepage.     */    public function actionLogout() {        Yii::app()->user->logout();        $this->redirect('login');    }}

I wonder if windows has included some sort of marker at the beginning of the file that PHP in linux is choking on. Which editor do you use for coding?

If you have the option, I’d highly recommend developing in linux if you’re targeting a linux server.

I am developing on netbeans but my old webhost had linux too and i didnt have this problem

Different OS versions and PHP versions will behave differently, and then there’s the minefield of the server’s PHP configuration. If you can upload the file, I’ll see if I can spot anything in the file itself. Other than that, I’m not sure what would cause that error. You may need to exercise your google-fu.