qazwsx Posted February 13, 2009 Share Posted February 13, 2009 Hey guys, here's the error today! switch($this->_getParam('application-action')) { case 'approve': if ($ride->ride_spaces_available == $ride->ride_spaces_taken) { $this->_helper->getHelper('FlashMessenger')->addMessage('All available spaces have been taken. If you want to approve this user, you must remove another user.', 'notice'); } else { // Make sure the ride isn't full $ride->ride_spaces_taken++; $ride->save(); $application->current()->application_changed = time(); $application->current()->application_status = Application::APPLICATION_STATUS_APPROVED; $user = $users->find($application->current()->application_user_id)->current(); $this->view->ride = $ride; $this->view->user = $user; What happens is, the ride_spaces_avaliable equals 2 and the ride_spaces_taken equals 0, yet it is still giving me the "All available spaces have been taken. If you want to approve this user, you must remove another user" error, even though they are no way equal. It is obviously taking the values from mysql, which I have checked and equal 2 and 0 respectively. Btw, I am using Zend Framework Any help would be greatly appreciated Quote Link to comment https://forums.phpfreaks.com/topic/145044-weird-php-error/ Share on other sites More sharing options...
gevans Posted February 13, 2009 Share Posted February 13, 2009 switch($this->_getParam('application-action')) { die(ride->ride_spaces_available.' == '.$ride->ride_spaces_taken); case 'approve': if ($ride->ride_spaces_available == $ride->ride_spaces_taken) { $this->_helper->getHelper('FlashMessenger')->addMessage('All available spaces have been taken. If you want to approve this user, you must remove another user.', 'notice'); } Put that in place and see what prints to screen, as from what you're saying they have to be equal. Quote Link to comment https://forums.phpfreaks.com/topic/145044-weird-php-error/#findComment-761191 Share on other sites More sharing options...
qazwsx Posted February 14, 2009 Author Share Posted February 14, 2009 That is spitting out this: Parse error: syntax error, unexpected T_EXIT, expecting T_CASE or T_DEFAULT or '}' in /home/james1/application/controllers/AccountController.php on line 140 Note: Line 140 = "die(ride->ride_spaces_available.' == '.$ride->ride_spaces_taken);" Thanks Quote Link to comment https://forums.phpfreaks.com/topic/145044-weird-php-error/#findComment-761861 Share on other sites More sharing options...
btherl Posted February 14, 2009 Share Posted February 14, 2009 The die() should go here instead: switch($this->_getParam('application-action')) { case 'approve': die(ride->ride_spaces_available.' == '.$ride->ride_spaces_taken); if ($ride->ride_spaces_available == $ride->ride_spaces_taken) { The reason being that code is not allowed after a switch but before a case (as php would not know which case it is supposed to be executed in). Quote Link to comment https://forums.phpfreaks.com/topic/145044-weird-php-error/#findComment-761988 Share on other sites More sharing options...
DeanWhitehouse Posted February 14, 2009 Share Posted February 14, 2009 die(ride->ride_spaces_available.' == '.$ride->ride_spaces_taken should be die($ride->ride_spaces_available.' == '.$ride->ride_spaces_taken Quote Link to comment https://forums.phpfreaks.com/topic/145044-weird-php-error/#findComment-762103 Share on other sites More sharing options...
qazwsx Posted February 16, 2009 Author Share Posted February 16, 2009 Ok, we're getting close now. This time it's telling me: Notice: Undefined property: Zend_Db_Table_Rowset::$application_ride_id in /home/james1/application/controllers/AccountController.php on line 112 Notice: Trying to get property of non-object in /home/james1/application/controllers/AccountController.php on line 143 Notice: Trying to get property of non-object in /home/james1/application/controllers/AccountController.php on line 143 == Line 143 = "die($ride->ride_spaces_available.' == '.$ride->ride_spaces_taken);" Line 112 = "elseif (!($ride = $rides->find($application->application_ride_id))) { $this->_helper->getHelper('FlashMessenger')->addMessage('Could not link ride', 'failure');" Quote Link to comment https://forums.phpfreaks.com/topic/145044-weird-php-error/#findComment-763109 Share on other sites More sharing options...
btherl Posted February 16, 2009 Share Posted February 16, 2009 Ok the root problem there is in $rides->find($application->application_ride_id). I can't help you more unfortunately, as I'm not familiar with the framework. But if you fix that, the second problem (line 143) should fix itself. Quote Link to comment https://forums.phpfreaks.com/topic/145044-weird-php-error/#findComment-763119 Share on other sites More sharing options...
qazwsx Posted February 18, 2009 Author Share Posted February 18, 2009 I changed it around a little but still can't get it to work. If you need more code just PM me and we will post the solution here if we find it. Quote Link to comment https://forums.phpfreaks.com/topic/145044-weird-php-error/#findComment-764873 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.