Jump to content
php.lv forumi

dzēst datus


ziedinjsh

Recommended Posts

šā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

Link to comment
Share on other sites

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 by codez
Link to comment
Share on other sites

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 by labaiss
Link to comment
Share on other sites

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 :?

Link to comment
Share on other sites

<?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 by labaiss
Link to comment
Share on other sites

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 by nemakuphp
Link to comment
Share on other sites

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!";
}
?>

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...