delete dataset ????

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
joecrack
Forum Commoner
Posts: 99
Joined: Mon Oct 31, 2005 9:17 pm

delete dataset ????

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

hint: $month
joecrack
Forum Commoner
Posts: 99
Joined: Mon Oct 31, 2005 9:17 pm

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

post. your. new. code.
joecrack
Forum Commoner
Posts: 99
Joined: Mon Oct 31, 2005 9:17 pm

Post 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.";
    }
?>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

are you 100% sure your submitted data matches records?
joecrack
Forum Commoner
Posts: 99
Joined: Mon Oct 31, 2005 9:17 pm

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

mysql_affected_rows() takes a single argument: the resource ID.
joecrack
Forum Commoner
Posts: 99
Joined: Mon Oct 31, 2005 9:17 pm

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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().
joecrack
Forum Commoner
Posts: 99
Joined: Mon Oct 31, 2005 9:17 pm

Post 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
Post Reply