Using usercake, I added an extra field to the registration page to record a users interests and store it in a table called interests.
Since I not storing in the same table I needed to create a separate query like the following. Please take note that the user supplied data in being turned into an array.
Here is my query:
//add interests1
$interestsArray = explode(',', $this->interests);
$interests1 = $interestsArray[0];
$interests2 = $interestsArray[1];
$interests3 = $interestsArray[2];
$interests4 = $interestsArray[3];
$interests5 = $interestsArray[4];
$this->interests1 = sanitize($interests1);
$this->interests2 = sanitize($interests2);
$this->interests3 = sanitize($interests3);
$this->interests4 = sanitize($interests4);
$this->interests5 = sanitize($interests5);
$stmt = $mysqli->prepare("INSERT INTO ".$db_table_prefix."interests (
interest
)
VALUES (
?
)");
$stmt->bind_param("s", $this->interests1);
$stmt->execute();
$stmt->close();
However I am getting the following error:
Fatal error: Call to a member function bind_param() on a non-object in /path/models/class.newuser.php on line 218
But there is not line 218 in the code... leaving me confused. I am hoping to eventually store each variable in the array in the column on separate rows. What do you guys suggest?
A link to the whole class if it helps is here: linktocode