ziedinjsh Posted November 10, 2010 Report Share Posted November 10, 2010 šāds ir links ar ko dzēš datus: <a href='delete_d7.php?del=".$data['d7_id']."'>Delete</a> un delete_d7.php <?php if($_GET='del'){ $sql = "DELETE FROM d7 WHERE d7_id='".$data['d7_id']."'"; $result = mysql_query($sql); header('location:index.php?id=add_d7&d7=list'); } ?> bet nekas nenotiek Quote Link to comment Share on other sites More sharing options...
codez Posted November 10, 2010 Report Share Posted November 10, 2010 (edited) visas darbības, kas veic kādas izmaiņas dara ar POST, plus par parametu sūta kādu pirms tam lapā uzģenerētu token-u. Savādāk, es tev aizsūtīšu linku, kurš kaut ko dzēš, tu viņā ieiesi un tev negribot, kaut kas tiks izdzēsts. Plus $_GET ir masīvs, nevis skaitļa vai string-a vērtība. Edited November 10, 2010 by codez Quote Link to comment Share on other sites More sharing options...
xPtv45z Posted November 10, 2010 Report Share Posted November 10, 2010 haha :D if($_GET='del'){ Kas ir tas? Šis te, noteikti, arī ir nepareizi. d7_id='".$data['d7_id']."' Quote Link to comment Share on other sites More sharing options...
Леший Posted November 10, 2010 Report Share Posted November 10, 2010 $sql = "DELETE FROM d7 WHERE d7_id='".$data['d7_id']."'"; Kurā vietā veidojās $data, izskaidro. Quote Link to comment Share on other sites More sharing options...
labaiss Posted November 10, 2010 Report Share Posted November 10, 2010 (edited) es saskatu līdzīgu problēmu, kas tev bija jau iepreikš http://php.lv/f/topic/17593-problema-ievadit-datus/ :D :D iepriekš tev arī parādās kaut kādi mistiski mainīgie, kuri pilnīgi neko neizpilda - tad kā tu vispār vari kaut ko veidot, ja nav pat saprašanas kam, kas paredzēts Edited November 10, 2010 by labaiss Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted November 10, 2010 Author Report Share Posted November 10, 2010 nu tagad ir šādi <?php if (isset($_POST['del'])) { $data = mysql_fetch_array(mysql_query("SELECT * FROM d7 WHERE d7_id='".$_GET['del']."")); $sql = "DELETE FROM d7 WHERE d7_id='".$_GET['del']'"; header('location: index.php?id=add_d7&d7=list'); } ?> bet tāpat nekas nenotiek :? Quote Link to comment Share on other sites More sharing options...
nemakuphp Posted November 10, 2010 Report Share Posted November 10, 2010 (edited) <?php if (isset($_POST['del'])) { $sql = "DELETE FROM d7 WHERE d7_id='".intval($_GET['del'])."'"; mysql_query($sql) or die ("Kļūda kverijā: ".mysql_error()); header('location: index.php?id=add_d7&d7=list'); } ?> Edited November 10, 2010 by nemakuphp Quote Link to comment Share on other sites More sharing options...
labaiss Posted November 10, 2010 Report Share Posted November 10, 2010 (edited) <?php $con = mysql_connect("localhost","user","parole"); if (!$con) { die('Kļūda: ' . mysql_error()); } mysql_select_db("db", $con); mysql_query("DELETE FROM tabula WHERE nosacijums='xxxx'"); mysql_close($con); ?> šitas strādā Edited November 10, 2010 by labaiss Quote Link to comment Share on other sites More sharing options...
nikidijs Posted November 10, 2010 Report Share Posted November 10, 2010 if (!empty($_GET['del'])) { //...kverijs... } Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted November 10, 2010 Author Report Share Posted November 10, 2010 <?php if (isset($_POST['del'])) { $sql = "DELETE FROM d7 WHERE d7_id='".intval($_GET['del'])."'"; mysql_query($sql) or die ("Kļūda kverijā: ".mysql_error()); header('location: index.php?id=add_d7&d7=list'); } ?> nop, neiet :? Quote Link to comment Share on other sites More sharing options...
nemakuphp Posted November 10, 2010 Report Share Posted November 10, 2010 (edited) Erroru vismaz neuzmeta nekādu? EDIT: Kas tev tur īsti ir - GET vai POST? <?php if (isset($_POST['del'])) { echo 'POST'; $sql = "DELETE FROM d7 WHERE d7_id='".intval($_POST['del'])."'"; mysql_query($sql) or die ("Kļūda kverijā: ".mysql_error()); header('location: index.php?id=add_d7&d7=list'); } elseif (isset($_GET['del'])) { echo 'GET'; $sql = "DELETE FROM d7 WHERE d7_id='".intval($_GET['del'])."'"; mysql_query($sql) or die ("Kļūda kverijā: ".mysql_error()); header('location: index.php?id=add_d7&d7=list'); } ?> Pasaki ko tev izvada Edited November 10, 2010 by nemakuphp Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted November 10, 2010 Author Report Share Posted November 10, 2010 nu šitā tagad iet <?php if (isset($_GET['del'])) { $data = mysql_fetch_array(mysql_query("SELECT * FROM d7 WHERE d7_id='".$_GET['del']."' LIMIT 1")); $sql = "DELETE FROM d7 WHERE d7_id ='".$data['d7_id']."'"; $result = mysql_query($sql); echo "Deleted!"; } ?> Quote Link to comment Share on other sites More sharing options...
daGrevis Posted November 10, 2010 Report Share Posted November 10, 2010 (edited) http://lmgtfy.com/?q=how+to+debug Edited November 10, 2010 by daGrevis 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.