From 23cf1b54e4976682606ac2e11ea4ee80f8a367a1 Mon Sep 17 00:00:00 2001 From: Johannes Kantz <67144859+JohannesKantz@users.noreply.github.com> Date: Thu, 12 Jan 2023 14:28:40 +0100 Subject: [PATCH] fix: insert vales with single quotes --- BancaDati/BancaDati.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/BancaDati/BancaDati.php b/BancaDati/BancaDati.php index 50ab02b..79de0e0 100644 --- a/BancaDati/BancaDati.php +++ b/BancaDati/BancaDati.php @@ -44,17 +44,19 @@ class BancaDati { $value = ""; $column = ""; foreach ($values as $col => $v){ - $value .= $v . ","; + $value .= "'" . $v . "'" . ","; $column .= $col . ","; } $value = trim($value, ","); $column = trim($column, ","); - $sql = "INSERT INTO $table($column) VALUES ($value);"; + $sql = "INSERT INTO $table ($column) VALUES ($value);"; + var_dump($sql); try { $sth = $this->pdo->prepare($sql); $sth->execute(); }catch (PDOException $e){ + var_dump($e); die; } }