Syntax issue with Function Parameters

What is wrong with the syntax of this Function…


	function generateSurveyItem($dbc, $questionNo, $articleSurveyQuestionID, $surveyResponse=NULL, $errors[$articleSurveyQuestionID]){
	}

Apparently NetBeans didn’t like it when I added the last parameter: $errors[$articleSurveyQuestionID]… :-/

When I aaded to my call to the Function in another script, NetBeans seemed to be okay with this…


	$surveyItemArray[$articleSurveyQuestionID] = generateSurveyItem($dbc, $questionNo, $articleSurveyQuestionID, $surveyResponse, $errors[$articleSurveyQuestionID]);

Thanks,

Debbie

Netbeans is just an IDE so it may complain about something even though the syntax is perfectly legal php syntax (which does not look correct in this case)
So try to run your function. Do you get any php errors?
The function signature should be like this:

function generateSurveyItem($dbc, $questionNo, $articleSurveyQuestionID, $surveyResponse=NULL, $myParam){
}

You can them call this function the way you do now and the $errors[$articleSurveyQuestionID] that you pass to function will become the value of $myParam inside your function.

You’re not allowed to create an argument for a function in the form of an array key like above (which will result in a parse error). Just call the last argument as $errors, and then pass the $errors[$articleSurveyQuestionID] variable as a parameter to it:


function generateSurveyItem($dbc, $questionNo, $articleSurveyQuestionID, $surveyResponse=NULL, $errors){
}

Okay, thanks for the tip. (I would have never guessed that one!)

As it turns out, I may be able to just use a single variable there.

(Am stuck in the MOST COMPLICATED script I have ever written and drowning in several areas…) :frowning:

Thanks,

Debbie