Voici mon code :
<?php
require "../config.php";
mysql_connect(DB_HOST,DB_LOGIN,DB_PASS);
mysql_select_db(DB_BDD);
if(!empty($_POST)){
extract($_POST);
$sql="UPDATE news SET titre='$titre', contenu='$contenu' WHERE id=$id";
$req = mysql_query($sql) or die('Erreur SQL !<br/>'.$sql.'<br/>'.mysql_error());
echo "News modifiée";
echo "<a href=\"index.php\">Revenir aux articles</a>";
$_GET["id"]=$id;
}
Mon erreur :
J'ai même une deuxième erreur ...Erreur SQL !
UPDATE news SET titre='Fermeture', `contenu` ='Je ferme c'est nul lol' WHERE id=2
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'est nul lol' WHERE id=2' at line 1
<?php
require "../config.php";
mysql_connect(DB_HOST,DB_LOGIN,DB_PASS);
mysql_select_db(DB_BDD);
extract($_POST);
$sql="INSERT INTO news (titre,contenu) VALUES ('$titre','$contenu')";
$req = mysql_query($sql) or die('Erreur SQL !<br/>'.$sql.'<br/>'.mysql_error());
header ("Location: index.php");
?>
Erreur SQL !
INSERT INTO news (titre,contenu) VALUES ('Je t'aime','pas ')
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'aime','pas ')' at line 1