I am a beginner!
I have copied the following code exactly form a book. When I try and run it I get the following error:
Warning: Cannot use a scalar value as an array in C:\wamp\www\Netbeans\formclass.php on line 35
What is a scalar value and why can I not use it in an array
[php]
<?php class formclass { var $fields = array(); var $processor; var $submit = "Submit form"; var $Nfields = 0; function __construct($processor, $submit) { $this->processor = $processor; $this->submit = $submit; } function displayform() { echo ""; echo "{$this->fields[$j-1]['label']}: | \n"; echo "|
[/php]
and here is the code to display the form:
[php]
include_once (“formclass.php”);
echo “Create a form”;
$phone_form = new formclass(“process.php”, “Submit form”);
$phone_form->addField(“first_name”, “First name”);
$phone_form->addField(“last_name”, “Last name”);
$phone_form->addField(“phone”, “Phone”);
echo “
Please fill out the form
”;
$phone_form->displayform();
echo “”;
[/php]
Any help to learn more is greatly appreciated. I thank you in advance