Jump to content

undefined variable


dhmyers82

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.