|
Hello,
I'm having a problem with a component I am writing, specifically a survey form meant for a company project. I'll present it in two parts. The main problem is presented in part 1. Those who want to know more can read on to part two.
*****Part 1*****
One of my colleagues, on completing the survey and clicking submit, gets the error: Fatal error: Cannot use object of type JUser as array in /home/hpa/sites/dev/components/com_hrbpcalculator/models/hrbpcalculator.php on line 17 (this is with error_reporting -1 and display_errors on in .htaccess).
However, this is not an error I get myself when I complete this survey. Unless I am mistaken, this is a PHP, server-side problem, independent of anything an individual user might have (OS, browser) or be doing.
So, how is this possible? Have I overlooked something?
*****Part 2*****
A little more detail.
It is a survey component, with three pages. Starts on a form where users fill in personal info (name, organisation, etc.). When they submit the controller stores the post data in a jsession (not serialised), and they are sent to the next page, the survey itself. When they submit this the post data is taken, the user data is "get" from the jsession, and both are passed to a method in the model meant to store them in the database (Mysql). This is the method it appears to be choking on (but for my colleague only). This is the method (part of models/hrbpcalculator.php):
public function store ($response, $user) {
$db = JFactory::getDBO();
$title = $user['title']; // This is line 17, alluded to in the error above $fname = $user['fname']; $sname = $user['sname']; $org = $user['org']; $occ = $user['occ']; $email = $user['email']; $query = "INSERT INTO `#__hrbp_survey_response` " . "(survey_id, title, first_name, surname, organisation, " . "job_title, email) VALUES (1, '$title', '$fname', " . "'$sname', '$org', '$occ', '$email')"; $db->setQuery($query); $db->query();
$srvy_resp_id = $db->insertid(); $count = count($response);
for ($i = 1; $i <= $count; $i++) { $query = "INSERT INTO `#__hrbp_response_int` " . "(survey_response_id, question_id, response) " . "VALUES (".$srvy_resp_id.", ".$i.", " .$response[$i].")"; $db->setQuery($query); $db->query(); }
return true;
}
$response being the post data from the survey, $user being the post data from the user form (here I'm taking out the title, first name, surname, etc.). Is $user a special variable in php or something?
At no point in my component have I used JUser (to my knowledge, unless another object I am calling uses it).
I have tested this myself and get no error on my own browser (Iceweasel/Firefox on Debian GNU/Linux), nor any other browser I have tried (IE, Chrome/Chromium, Epiphany), nor any other OS (XP, Vista). My colleague has Firefox 5 on Vista (a combination I have tested elsewhere, which worked).
You can see why it has really stumped me. Any suggestions would be appreciated. Please say if I've omitted any useful information.
Thanks,
Dom
|