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; } ?> Link to comment https://forums.phpfreaks.com/topic/294395-undefined-variable/ Share on other sites More sharing options...
dhmyers82 Posted February 5, 2015 Author Share Posted February 5, 2015 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, ":"); Link to comment https://forums.phpfreaks.com/topic/294395-undefined-variable/#findComment-1504930 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.