Cannot Submit Code


#1

Cannot submit this code in Functions Part I even though it works.
\
The errors suggests I did not use 'array()' in my code.

Any ideas ?



<?php
// Create an array and push on the names
// of your closest family and friends
$family = array();
array_push($family, "Chris ", "Shell ", "Eva ", "Ash ");
// Sort the list
sort($family);
// Randomly select a winner!
$winnum = rand(0, 2);
$winner = $family[$winnum];
// Print the winner's name in ALL CAPS
print strtoupper($winner);
?>



#2

@chrisclarkproject
Try it with

<html>
    <p>
	<?php
	// Create an array and push on the names
    // of your closest family and friends
    $myArray=array("jan","piet");
    array_push($myArray,"klaas");
    array_push($myArray,"elLoco");
    sort($myArray);
    print count($myArray)." ";
    print strtoupper($myArray[round(rand(0,count($myArray)))])
	// Sort the list

	// Randomly select a winner!

	// Print the winner's name in ALL CAPS
	?>
	</p>
</html>

Reference

http://php.net/manual/en/language.types.array.php
http://php.net/manual/en/function.array-push.php
http://php.net/manual/en/array.sorting.php
http://php.net/manual/en/function.count.php
http://php.net/manual/en/function.rand.php


#3

Thank you Leonhard for your help. I think that the website freezes up during it's processing of code sometimes. Then, even when the correct code is entered, submitting and other actions are not available.


#4

@chrisclarkproject,
What you should understand ....
as soon as you have the combination of <?php and a closing ?>
in your =index.html= code
you are in direct contact with a server....
and if you enter the code in between it is as if you are operating on a open heart

So during the php-course
i would suggest
you remove the opening <?php before you enter your code....
and if you are satisfied with your code
open the server-comm by placing the opening <?php back in...

Then by =clicking= the Submit button
your code will be checked by the code checker.... which is something separate from the server-comm.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.