Page 1 of 1

delete dataset ????

Posted: Tue Nov 01, 2005 2:07 am
by joecrack
Hi
i made these codes:

Code: Select all

<html><body>
<form name="form1" method="post" action="del2.php">
  <input type="text" name="textfield">
  <input name="eqnr" type="submit" id="eqnr" value="Submit">
</form></body></html>

Code: Select all

<?php
    error_reporting(E_ALL);   
    $eqnr= (!empty($_POST['eqnr']) ? ($_POST['eqnr'])  : '');
    if (!empty($month))
    {   
         $connection = mysql_connect("localhost", "root", "") or die(mysql_error());
         mysql_select_db("safe",$connection) or die (mysql_error());
         $deleteresult = mysql_query("DELETE FROM `sam_artikel` WHERE eqnr = '".$eqnr."'") or die(mysql_error());
         $affected_rows = mysql_affected_rows($deleteresult,$connection);
         echo "<b>Check</b> was executed.";
    }
?>
But its not working. There is not even a Error message - just a blnak screen!
I hope someone can help me.
joe

Posted: Tue Nov 01, 2005 3:20 am
by feyd
hint: $month

Posted: Tue Nov 01, 2005 6:31 pm
by joecrack
Hi
i already corrected that one.
But now i get the message:

Check was executed."; } ?>

But it does not delete anything!
What could be the problem???
joe

Posted: Tue Nov 01, 2005 6:45 pm
by feyd
post. your. new. code.

Posted: Tue Nov 01, 2005 6:52 pm
by joecrack
Just $month changed:

Code: Select all

<?php
    
error_reporting(E_ALL); 
$eqnr= (!empty($_POST['eqnr']) ? ($_POST['eqnr'])  : '');
    
    if (!empty($eqnr))
    {      
         $connection = mysql_connect("localhost", "root", "") or die(mysql_error()); 
         mysql_select_db("safe",$connection) or die (mysql_error());
         $deleteresult = mysql_query("DELETE FROM `sam_artikel` WHERE eqnr = '".$eqnr."'") or die(mysql_error());
         $affected_rows = mysql_affected_rows($deleteresult,$connection);
         echo "<b>Check</b> was executed.";
    }
?>

Posted: Tue Nov 01, 2005 7:02 pm
by feyd
are you 100% sure your submitted data matches records?

Posted: Tue Nov 01, 2005 7:17 pm
by joecrack
Hoy

i dodnt know why, but suddenly i get an error:

Code: Select all

Warning: Wrong parameter count for mysql_affected_rows() in C:\Server\xampp\htdocs\del2.php on line 19
Check was executed.
So whats wrong with that?

Posted: Tue Nov 01, 2005 7:27 pm
by feyd
mysql_affected_rows() takes a single argument: the resource ID.

Posted: Tue Nov 01, 2005 7:32 pm
by joecrack
so you mean like there cant be a eqnr in the database - or what?
i am just not sure about these lines:

Code: Select all

$eqnr= (!empty($_POST['eqnr']) ? ($_POST['eqnr'])  : '');
    
    if (!empty($eqnr))
I just did copy/paste and changed to eqnr :roll: !!!
Why in $eqnr its two times like nearly the same?
shall i give a link with pic of my database or anything else!?!?!
sorry i am a damn noob :?:
thx

Posted: Tue Nov 01, 2005 7:38 pm
by feyd
I mean exactly as I said: the function you are calling to see how many rows were removed (mysql_affected_rows()) will only accept one argument, the resource ID, which is returned from mysql_query().

Posted: Tue Nov 01, 2005 7:50 pm
by joecrack
Hi
sorry - sometimes i got some problems understanding you (i am from germany=)
so you mean just like that:

Code: Select all

$affected_rows = mysql_affected_rows($deleteresult);
???
still same error.
joe