0
I’m in serious trouble with the INSERT
of PDO
, I am unable to add the values correctly to the banco de dados
, how to proceed in this situation?
I’m waiting for help.
<?php
if (isset($_POST['btn-send-ticket'])) {
$name = filter_input(INPUT_POST, 'name');
$subject = filter_input(INPUT_POST, 'subject');
$categorys = filter_input(INPUT_POST, 'category');
$prioritys = filter_input(INPUT_POST, 'prioritys');
$message = filter_input(INPUT_POST, 'message');
if (empty($subject)) {
$error[] = 'The <strong>subject</strong> field can not be empty';
} elseif (empty($message)) {
$error[] = 'The <strong>message</strong> field can not be empty';
} else {
try {
$sqli = "INSERT INTO member_ticket (name, subject, category, priority, message, date, status) VALUES (:name, :subject, :category, :priority, :message, NOW(), 0)";
$insert = $db->prepare($sqli);
$insert->bindParam(":name", $name, PDO::PARAM_STR);
$insert->bindParam(":subject", $subject, PDO::PARAM_STR);
$insert->bindParam(":category", $categorys, PDO::PARAM_STR);
$insert->bindParam(":priority", $prioritys, PDO::PARAM_STR);
$insert->bindParam(":message", $message, PDO::PARAM_STR);
$insert->execute();
$success[] = 'Your support request has been successfully opened, will soon be answered thanks.';
} catch (PDOException $e) {
echo $e->getMessage() . '<br/>' . $e->getLine();
exit;
}
}
}
?>
Thanks for commenting, I added an update to the topic. I don’t know how to properly explain my problem, but I tried to see: Note that when passing :name, :Subject, etc... to the query, the
PDO
is not treating the query, is inserting what was to be treated.– Guilherme SpinXO
Now I understand :D
– user28595