Welcome Guest, Not a member yet? Register   Sign In
Undefined offset . How to rid this error?
#3

[eluser]vitoco[/eluser]
if your exploded string transforms always into a 2 position array, you can check that in 2 possible ways

Code:
$parts = explode("-",$code);

// MUST BE 2 PARTS
if( count( $parts ) != 2 )
{
    echo 'error';
    exit();
}

// CHECK SECOND POSITION : CAN BE A N > 2 POSITIONS
if( ! isset( $parts[ 1 ] ) )
{
    echo 'error';
    exit();
}

$code    = $parts[ 0 ];
$userid  = $parts[ 1 ];

if ($code != NULL && $userid != NULL && $user->exists()) {

Also, indexes assigned to the array via explode() are int, no need to put it inside ''

Saludos


Messages In This Thread
Undefined offset . How to rid this error? - by El Forum - 08-14-2012, 01:55 PM
Undefined offset . How to rid this error? - by El Forum - 08-14-2012, 02:07 PM
Undefined offset . How to rid this error? - by El Forum - 08-14-2012, 02:08 PM
Undefined offset . How to rid this error? - by El Forum - 08-14-2012, 02:13 PM
Undefined offset . How to rid this error? - by El Forum - 08-14-2012, 02:17 PM
Undefined offset . How to rid this error? - by El Forum - 08-14-2012, 02:37 PM
Undefined offset . How to rid this error? - by El Forum - 08-14-2012, 10:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB