Jump to content

Weird PHP Error


qazwsx

Recommended Posts

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 :)

Link to comment
Share on other sites

      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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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');"

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.