Fix issue #10, newlines should be showing up now

Took 27 minutes
This commit is contained in:
2020-10-04 21:04:25 +02:00
parent 10ae17b246
commit c2fe6c4d08
4 changed files with 29 additions and 14 deletions

View File

@ -83,14 +83,14 @@ class FaqModel
public function addQuestion(int $room_id, string $question, string $nickname )
{
$stmnt = Database::getConnection()->prepare( 'INSERT INTO questions ( room_id, question, created_by ) VALUES ( :room_id, :question, :created_by )' );
$stmnt->execute( array( 'room_id' => $room_id, 'question' => htmlspecialchars( $question ), 'created_by' => $nickname ) );
$stmnt->execute( array( 'room_id' => $room_id, 'question' => htmlspecialchars($question, ENT_QUOTES, 'UTF-8'), 'created_by' => $nickname ) );
}
public function addAnswer(int $question_id, string $answer)
{
$stmnt = Database::getConnection()->prepare( 'UPDATE questions SET answer = :answer WHERE id = :id' );
$stmnt->execute( array( 'answer' => htmlspecialchars( $answer ), 'id' => $question_id ) );
$stmnt->execute( array( 'answer' => htmlspecialchars($answer, ENT_QUOTES, 'UTF-8'), 'id' => $question_id ) );
}
@ -123,7 +123,7 @@ class FaqModel
{
return false;
}
$result['question'] = str_replace( "\n", '<br>', $result['question'] );
return $result;
}
}