views:

1028

answers:

4

I'm getting this error and I can't make head or tail of it.

The exact error message is:

Fatal error: Can't use function return value in write context in /home/curricle/public_html/descarga/index.php on line 48

Line 48 is:

if (isset($_POST('sms_code') == TRUE ) {

Anybody knows what's going on???

PS Here's the full function, in case it helps:

function validate_sms_code() {

    $state = NOTHING_SUBMITED;

    if (isset($_POST('sms_code') == TRUE ) {
     $sms_code = clean_up($_POST('sms_code'));
     $return_code = get_sepomo_code($sms_code);

     switch($return_code) {

      case 1:
       //no error
       $state = CORRECT_CODE;
       break;

      case 2:
       // code already used
       $state = CODE_ALREADY_USED;
       break;

      case 3:
       // wrong code
       $state = WRONG_CODE;
       break;

      case 4:
       // generic error
       $state = UNKNOWN_SEPOMO_CODE;
       break;

      default:
       // unknown error
       $state = UNKNOWN_SEPOMO_CODE;
       throw new Exception('Unknown sepomo code: ' . $return_code);
       break;
     }

    } else {
     $state = NOTHING_SUBMITED;
    }
    dispatch_on_state($state);
}
+5  A: 

You mean

if (isset($_POST['sms_code']) == TRUE ) {

though incidentally you really mean

if(isset($_POST['sms_code'])) {
chaos
Aaaaaaarrrrggghhhh!!!! :-P
Fernando
+3  A: 
if (isset($_POST('sms_code') == TRUE ) {

change this line to

if (isset($_POST['sms_code']) == TRUE ) {

You are using parentheseis () for $_POST but you wanted square brackets []

:)

OR

if (isset($_POST['sms_code']) && $_POST['sms_code']) { 
//this lets in this block only if $_POST['sms_code'] has some value
Wbdvlpr
Nope, you cannot write "if (isset($_POST['sms_code'] == TRUE ) {", there's a missing ")".
middus
corrected :P ..
Wbdvlpr
+1  A: 

Your code:

if (isset($_POST('sms_code') == TRUE ) {

Watch your parentheses:

if (isset($_POST['sms_code']) == TRUE ) {

you mixed up [ and ( and forgot to close one.

Even better:

if (isset($_POST['sms_code'])) {

because isset returns a boolean anyway.

middus
+1  A: 

This also happens when using empty on a function return. example:

!empty(trim($someText)) and doSomething()

because empty is not a function but a language construct (not sure), and it only takes variables examples: Yes:

empty($someVar)

No:

empty(someFunc())
rolfen