Re: Probleme with MySQL queries
| From: | Kendo Tom | Date: | Wed, 03 Sep 2008 09:17:51 +0000 |
| Subject: | Re: Probleme with MySQL queries | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-45307@lists.php.net to get a copy of this message | ||
Hi ,
For this situation , you should print out the SQL statement to check the value of the variable "$var" .-------------------------------------------------- From: "David DURIEUX" <d.durieux@siprossii.com> Sent: Wednesday, September 03, 2008 5:07 PM To: <php-db@lists.php.net> Subject: [PHP-DB] Probleme with MySQL queries
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 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php