Gossamer
Active member
Hello! So, I'm trying to pass the variable $ExistingReserve from my Controller into a template. However, when the template loads I receive this error:
Here is the relevant part of my ControllerPublic:
And my model with the getReserveByUser function:
It looks like the error comes from how I'm attempting to set $ExistingReserve using the getReserveByUser function. What's the correct way to pass the information?
Template Errors: goss_reserves
- htmlspecialchars() expects parameter 1 to be string, array given in C:\xampp\htdocs\Xenforo_DEV\library\XenForo\Template\Abstract.php(265) : eval()'d code, line 5:
4:
5: Test: ' . htmlspecialchars($ExistingReserve, ENT_QUOTES, 'UTF-8') . '
6:
Here is the relevant part of my ControllerPublic:
PHP:
public function actionIndex()
{
//Check for Existing Reserve
$visitor = XenForo_Visitor::getInstance();
$reserveModel = $this->_getReserveModel();
if($reserveModel->getReserveByUser($visitor['user_id']))
{
$ExistingReserve = $reserveModel->getReserveByUser($visitor['user_id']);
}
else
{
$ExistingReserve = 0;
}
//Get all rows from our table and other data to pass to the template so it can be used
$viewParams = array(
'Reserves' => $this->_getReserveModel()->getAllReserves(),
'ExistingReserve' => $ExistingReserve);
return $this->responseView('Reservations_ViewPublic_Reserves', 'goss_reserves', $viewParams);
}
And my model with the getReserveByUser function:
PHP:
public function getReserveByUser($user_id)
{
return $this->_getDb()->fetchRow('SELECT * FROM xf_goss_reservation WHERE user_id = ?', $user_id);
}