Cibiņš Posted October 21, 2009 Report Share Posted October 21, 2009 Kādēļ neizpilda rindas dzēšanas operāciju? test.php <? include ('dbConfig.php'); if(!isset($cmd)) { $result = mysql_query("select * from news order by id"); while($r=mysql_fetch_array($result)) { $title=$r["title"]; $id=$r["id"]; echo "<a href='delete.php?cmd=delete&id=$id'>$title - Delete</a>"; echo "<br>"; } } ?> delete.php <? include ('dbConfig.php') if($_GET["cmd"]=="delete") { $sql = "DELETE FROM news WHERE id=$id"; $result = mysql_query($sql); echo "Rinda izdzēsta!"; } ?> Quote Link to comment Share on other sites More sharing options...
briedis Posted October 21, 2009 Report Share Posted October 21, 2009 (edited) Pie dzēšanas, kur tu vispār dabūt to $id? delete.php augšā pieliec rindiņu $id = $_GET['id'] Un neaizmirsti izmantot mysql_real_escape_string() funkciju. Edited October 21, 2009 by briedis Quote Link to comment Share on other sites More sharing options...
Cibiņš Posted October 21, 2009 Author Report Share Posted October 21, 2009 <? include ('dbConfig.php') $id = $_GET['id']; if($_GET['cmd']=="delete") { $sql = "DELETE FROM news WHERE id=$id"; $result = mysql_query($sql); echo "Row deleted!"; } ?> Nu nestrādā vienalga! Quote Link to comment Share on other sites More sharing options...
briedis Posted October 21, 2009 Report Share Posted October 21, 2009 Varbūt pateiksi kādu kļūdas paziņojumu? Un starpcitu, lai zinātu cik rindas ir ietekmētas (dzēstas vai mainītas) ir jāizmanto myqsl_affected_rows(). Quote Link to comment Share on other sites More sharing options...
Cibiņš Posted October 21, 2009 Author Report Share Posted October 21, 2009 Varbūt pateiksi kādu kļūdas paziņojumu? Nekādi kļūdas paziņojumus nerāda. Vajag rādīt Row deleted ja operācija ir izpildīta bet nerāda pilnīgi neko. Balta lapa vienkārši. Quote Link to comment Share on other sites More sharing options...
briedis Posted October 21, 2009 Report Share Posted October 21, 2009 Kļūdu paziņojumu rādīšana ir ieslēgta? Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted October 21, 2009 Report Share Posted October 21, 2009 aiz include ('dbConfig.php') ieliec semikolu Quote Link to comment Share on other sites More sharing options...
Cibiņš Posted October 21, 2009 Author Report Share Posted October 21, 2009 aiz include ('dbConfig.php') ieliec semikolu Pamanīju jau ka semikols nebij aiz tā include, kā jau tradicionāla aizmāršības kļūda. Paldies, viss strādā ;) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.