Probleme with MySQL queries
| From: | David DURIEUX | Date: | Wed, 03 Sep 2008 09:07:46 +0000 |
| Subject: | Probleme with MySQL queries | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-45305@lists.php.net to get a copy of this message | ||
Hello
There is a problem when I select a line in mysql table and afet I
delete it.
1/ It works :
$sql = 'SELECT * FROM table WHERE id="10" ';
$req = mysql_query($sql) or die('Erreur SQL
!<br>'.$sql.'<br>'.mysql_error());
while($data = mysql_fetch_assoc($req)) {
echo $data['id'];
}
$sql2 = 'DELETE FROM table WHERE id="10" ';
$req2 = mysql_query($sql2) or die('Erreur SQL
!<br>'.$sql2.'<br>'.mysql_error());
2/ It don't work :
$sql = 'SELECT * FROM table WHERE id="'.$var.'" ';
$req = mysql_query($sql) or die('Erreur SQL
!<br>'.$sql.'<br>'.mysql_error());
while($data = mysql_fetch_assoc($req)) {
echo $data['id'];
}
$sql2 = 'DELETE FROM table WHERE id="'.$var.'" ';
$req2 = mysql_query($sql2) or die('Erreur SQL
!<br>'.$sql2.'<br>'.mysql_error());
Results of this queries :
In first case (it works) : I see the id get in mysql and it delete it
after
In second case (it don't work) : I don't see id get in mysql. It's like
if it delete it first and after select.
I have not error in php log.
If somebody can help me, because I try since few hours...
Best regards,
David DURIEUX
Tel : +33 (0)4.74.04.81.34
Port : +33 (0)6.34.99.45.18
Mail : d.durieux@siprossii.com
Site Web : http://www.siprossii.com/
SIPROSSII
847 route de Frans (Créacité)
69400 Villefranche sur Saône