13
list(,,,,,,,,,$user, $pass) = explode("\t", $line);
if(trim($user) == $_POST['username'] && trim($pass) == $_POST['password'] )

The message undefined offset 10 , The message undefined offset 9 . the 9 and the 10 is the $user and $pass. How do i fix the error? and does undefined offset means its not being declared or something? and theres alot of ,,,,,,,, is because theres value but i dont need it for this php

1 Answer 1

32

undefined offset in this context means that you are expecting more parameters in your call to list than are in the array on the right hand of the equation.

You are expecting an array with a length of 11 but explode("\t", $line) is returning an array of less than 11 values.

You either need to ensure you have the right amount of tab separated values in $line or pad the output of explode using array_pad.

Below is an example of using array_pad to make sure the array has a length of 11:

list(,,,,,,,,,$user, $pass) = array_pad(explode("\t", $line), 11, null);

If $line did not contain enough tab separated values then $user and $pass would take the value null.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.