par
uPong » 29 mars 2016, 20:42
Bonjour j'ai un soucis pour faire un système de news ... j'obtiens une erreur mais je sais pas d'où elle vient , j'ai du mal à la localiser ... pouvez vous m'aider ?
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 :
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
J'ai même une deuxième erreur ...
<?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
Bonjour j'ai un soucis pour faire un système de news ... j'obtiens une erreur mais je sais pas d'où elle vient , j'ai du mal à la localiser ... pouvez vous m'aider ?
Voici mon code :
[php]<?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;
}[/php]
Mon erreur :
[quote]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[/quote]
J'ai même une deuxième erreur ...
[php]<?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");
?>[/php]
[quote]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[/quote]