dhmyers82 Posted February 5, 2015 Share Posted February 5, 2015 Having issues with an in book problem. I keep getting and "Undefined variable" Notice on the line that starts with "while ($currField != NULL) {" I am assuming it has something to do with the not NULL but I have no clue on this one folks. <?php error_reporting(E_ALL); ini_set('display_errors', 'on'); $record = "jdoe:8W4dS03a39Yk2:1463:24:John Doe:/home/jdoe:/bin/bash"; $passwordFields = array( "login name", "optional encrypted password", "numerical user ID", "numerical group ID", "user name or comment field", "user home directory", "optional user command interpreter"); $fieldIndex = 0; $extraFields = strtok($record, ":"); while ($currField != NULL) { if ($fieldIndex < count($passwordFields)) echo "<p>The {$passwordFields[$fieldIndex]} is <em>$currField</em></p>\n"; else { ++$extraFields; echo "<p>Extra Field # $extraFields is <em>$currField</em></p>\n"; } $currField = strtok(":"); ++$fieldIndex; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/294395-undefined-variable/ Share on other sites More sharing options...
Solution dhmyers82 Posted February 5, 2015 Author Solution Share Posted February 5, 2015 (edited) Nevermind, Thank you. Sorry I combined two lines from my book and saw it as soon as I went back to look again. $extraFields = 0; $currField = strtok($record, ":"); Edited February 5, 2015 by dhmyers82 Quote Link to comment https://forums.phpfreaks.com/topic/294395-undefined-variable/#findComment-1504930 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.