Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
joecrack
Forum Commoner
Posts: 99 Joined: Mon Oct 31, 2005 9:17 pm
Post
by joecrack » Tue Nov 01, 2005 2:07 am
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
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Nov 01, 2005 3:20 am
hint: $month
joecrack
Forum Commoner
Posts: 99 Joined: Mon Oct 31, 2005 9:17 pm
Post
by joecrack » Tue Nov 01, 2005 6:31 pm
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
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Nov 01, 2005 6:45 pm
post. your. new. code.
joecrack
Forum Commoner
Posts: 99 Joined: Mon Oct 31, 2005 9:17 pm
Post
by joecrack » Tue Nov 01, 2005 6:52 pm
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.";
}
?>
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Nov 01, 2005 7:02 pm
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 » Tue Nov 01, 2005 7:17 pm
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?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Nov 01, 2005 7:27 pm
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 » Tue Nov 01, 2005 7:32 pm
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
!!!
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
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Nov 01, 2005 7:38 pm
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 » Tue Nov 01, 2005 7:50 pm
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