Answer the question
In order to leave comments, you need to log in
DB insert query not working. How to fix?
INSERT query not working
$cat = $_POST['cat'];
$title = $_POST['title'];
$keyw = $_POST['keywords'];
$descr = $_POST['description'];
$textt = $_POST['text'];
$hard = $_POST['hard'];
$mini_img = $_POST['mini_img'];
$source = $_POST['source'];
$file = $_POST['file'];
$file_size = $_POST['file_size'];
$demo = $_POST['demo'];
$syntax = $_POST['syntax'];
$view = 0;
$author = "Николай Чахов";
echo "<pre>";
var_dump ($_POST);
echo "</pre>";
$query = "INSERT INTO `post` (`post_id`, `cat`, `title`, `keywords`, `description`, `text`, `hard`, `mini_img`, `author`, `source`, `file`, `file_size`, `demo`, `date', `view`, `syntax`)
VALUES (' ',$cat,$title,$keywords,$description,$text,$hard,$mini_img,$author,$source,$file,$file_size,$demo, NOW(),$view,$syntax)";
$result = $con->query($query);
if ($result == true){
echo "<p>Информация занесена в базу данных</p>";
} else {
echo "<p>Информация не занесена в базу данных</p>";
echo('Ошибка : ('. $con->connect_errno .') '. $con->connect_error);
}
Answer the question
In order to leave comments, you need to log in
No wonder it doesn't work. Everything is wrong here.
$query = "INSERT INTO `post` (`post_id`, `cat`, `title`, `keywords`, ...)
VALUES (null,?,?,?, ..., NOW(),?,?)";
$stmt = $con->prepare($query);
$stmt->bind_param("sss...", $cat,$title,$keywords, ...);
$stmt->execute();
echo "<p>Информация занесена в базу данных</p>";
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question