Is this php/mysql expression (which sets the timezone of connection) safe enough?

StackOverflow https://stackoverflow.com/questions/22138215

  •  19-10-2022
  •  | 
  •  

Вопрос

Is this expression is safe or does this approach has vulnerabilities?

$pdo = new PDO('mysql:host=localhost;dbname=test', 'user', 'password');
$pdo->exec('SET time_zone = "' . date_default_timezone_get() . '"');

Нет правильного решения

Другие советы

I would check first if date_default_timezone_get() returns a valid value, to avoid a query like: SET time_zone = "".

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top