Jump to content

undefined variable


Go to solution Solved by 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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.