QUERY FAILED .You have an error in your SQL syntax; check the manual that corres
Résolu
mm
-
mm -
mm -
Bonjour j'ai un soucis avec mon code php, j'arrive pas voir l'erreur.
Grandement besoin de votre aide. Le code est ci-dessous.
Grandement besoin de votre aide. Le code est ci-dessous.
<?php
if(isset($_POST['create_post'])){
$post_title = escape($_POST['title']);
$post_user = escape($_POST['post_user']);
$post_category_id = escape($_POST['post_category']);
$post_status = escape($_POST['post_status']);
$post_image = escape($_FILES['image']['name']);
$post_image_temp = escape($_FILES['image']['tmp_name']);
$post_tags = escape($_POST['post_tags']);
$post_content = escape($_POST['post_content']);
$post_date = escape(date('d-m-y'));
// $post_comment_count = 4;
move_uploaded_file($post_image_temp, "../images/$post_image");
// la fonction qui nous permet d'inserer nos données dans la base de données
$query = "INSERT INTO posts(post_category_id, post_title, post_user, post_date,post_image,post_content,post_tags,post_status) ";
$query .= "VALUES({$post_category_id},'{$post_title}','{$post_user}',now(),'{$post_image}','{$post_content}','{$post_tags}', '{$post_status}') ";
$create_post_query = mysqli_query($connexion, $query);
comfirmQuery($create_post_query);
$the_post_id = mysqli_insert_id($connexion);
echo "<p class='bg-success'>Post Created. <a href='../post.php?p_id={$the_post_id}'>View Post </a> or <a href='posts.php'>Edit More Posts</a></p>";
}
?>
A voir également:
- You have an error in your sql syntax; check the manual that corresponds to your mariadb server version for the right syntax to use near 'by
- You have an error in your sql syntax; check the manual that corresponds to your mariadb server version for the right syntax to use near at line 1 - Meilleures réponses
- Check the manual that corresponds to your mariadb server version for the right syntax - Meilleures réponses
- Qwerty to azerty - Guide
- Downloader for pc - Télécharger - Téléchargement & Transfert
- Dernière version ccleaner gratuit français - Télécharger - Nettoyage
- A link to the past - Accueil - Guide jeu vidéo
- Aux in - Forum Audio
5 réponses
bonjour,
affiche (echo) la valeur de ta variable $query.
ensuite, utilise-la hors php, par exemple dans phpmyadmin.
si tu ne comprends pas le soucis, partage ici ce que contient cette variable.
affiche (echo) la valeur de ta variable $query.
ensuite, utilise-la hors php, par exemple dans phpmyadmin.
si tu ne comprends pas le soucis, partage ici ce que contient cette variable.
Voici ce qu'il affiche avec echo.
INSERT INTO posts (post_category_id, post_title, post_user, post_date, post_image, post_content, post_tags, post_status) VALUES(,'','',now(),'','','','') QUERY FAILED .
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''','',now(),'','','','')' at line 1
INSERT INTO posts (post_category_id, post_title, post_user, post_date, post_image, post_content, post_tags, post_status) VALUES(,'','',now(),'','','','') QUERY FAILED .
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''','',now(),'','','','')' at line 1
Il manque la valeur post_ category_id, il ne l’a pris en compte alors que je l’ai bien défini .
$post_category_id = escape($_POST['post_category']);
$post_category_id = escape($_POST['post_category']);
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question