what is the request data containing prior to passing them on to the model? oh, and why dont u use the session component to access the session? your code will most certainly trigger lots of warnings
On 5 Nov., 00:20, Will <[email protected]> wrote: > Hi all, > > I'm using CakePHP 2.0 on a system running Windows 7, Apache 2, PHP 5.3 > and SQL Server. I'm using a User model and UsersController that are > essentially the same as the example in the online book. Here's my add > function: > > public function add() { > if($_SESSION['Auth']['User']['user_account_management'] != 1) > { > > $this->redirect(array('controller'=>'Employees','action' => > 'access_denied')); > } else { > if ($this->request->is('post')){ > $this->User->create(); > if ($this->User->save($this->request->data)) { > $this->Session->setFlash(__('The user > has been saved')); > $this->redirect('/users'); > } else { > $this->Session->setFlash(__('The user > could not be saved. > Please, try again.')); > } > } > } > } > > When I try to add a new user with this function, I get a SQL Server > error: > > INSERT INTO [users] ([created], [modified], [username], [password], > [email]) VALUES ('NULL', 'NULL', N'username', N'hashed_password', > N'[email protected]') > > However, when I comment out the line "$this->User->create()", > everything saves fine. I'm not really sure what the create function > is even supposed to do in this context since you're saving the data > right below anyway. Could someone explain to me what create() is > supposed to do and why it might be causing this error? The truly > baffling part is that I deployed this app to a test server yesterday > and it worked just fine. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
