Не могу добавить комнтарии на php. Помогите пожалуйста
<?php
if (isset($_POST['do_post'])) {
$errors = array();
if ($_POST['name'] == '') {
$errors[] = 'input name!';
}
if ($_POST['text'] == '') {
$errors[] = 'input text!';
}
}
if (empty($errors)) {
mysqli_query($connection, "INSERT INTO `comments` (`autor`,`text`,`pubdate`,`
articles_id`) VALUES ('".$_POST['name']."', '".$_POST[
'text']."', NOW(), '".$art['id']."')");
echo 'OK';
}else{echo $errors[0];}
?>
Ответы (1 шт):
Автор решения: Eugene Evstafiev
→ Ссылка
Попробуйте отловить ошибку:
<?php
if (isset($_POST['do_post'])) {
$errors = array();
if ($_POST['name'] == '') {
$errors[] = 'input name!';
}
if ($_POST['text'] == '') {
$errors[] = 'input text!';
}
}
if (empty($errors)) {
if(!mysqli_query($connection, "INSERT INTO `comments` (`autor`,`text`,`pubdate`,`
articles_id`) VALUES ('".$_POST['name']."', '".$_POST[
'text']."', NOW(), '".$art['id']."')")) {
echo("Error description: " . mysqli_error($connection));
} else
echo 'OK';
}else{echo $errors[0];}
?>