Syntax Error

Par Abdi Farah, il y a 11 ans


Bonsoir,
Donc j'ai une erreur de syntax que je n'arrive pas a corriger :(
Erreur :

Error: syntax error, unexpected ''mail'' (T_CONSTANT_ENCAPSED_STRING), expecting ')'aroundFile: C:\wamp\www\cakephp-2.6.3\app\Controller\UsersController.phparoundLine: 12

Mon code (Controller) :

<?php App::uses('AppController' , 'Controller'); class UsersController extends AppController{ public function signup(){ if (!empty($this->request->data)) { $this->User->create($this->request->data); if($this->User->validates()){ $this->User->create(array( 'username' => $this->request->data['User']['username'], 'password' => $this->Auth->password($this->request->data['User']['password']) 'mail' => $this->request->data['User']['mail'] )); $this->User->save(); $this->Session->setFlash('Merci vous êtes inscrit'); } } } }

4 réponses

Carouge10, il y a 11 ans

Utiliser les " pour votre regex

Abdi Farah, il y a 11 ans

Fonctionne toujours pas :/

Carouge10, il y a 11 ans

Bonjour,
Il manque une virgule après la ligne pour le password.

Abdi Farah, il y a 11 ans

Cette erreur s'affiche alors que tout est juste
Warning (2): preg_match(): Delimiter must not be alphanumeric or backslash [CORE\Cake\Model\Validator\CakeValidationRule.php, line 279]

Mon code :

<?php class User extends AppModel{ public $validate = array( 'username' => array( 'rule' => '/^[a-z0-9A-Z]*$/', 'message' => 'Votre nom d\'utilisateur n\'est pas valide' ), 'mail' => array( 'rule' => 'email' ), 'password' => array( 'rule' => 'notEmpty' ), 'password2' => array( 'rule' => 'identicalFields' ) ); public function indenticalFields($check, $limit){ return $check['password2'] = $this->data['User']['password']; } }