Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to confirm row deletion from MySql table

Status
Not open for further replies.

leehinkleman

Programmer
Feb 14, 2002
83
NZ
The attempt to produce the second die error,
'die("can't delete")'
in the following code seems to have no effect.
Names known to exist in the namepass table are deleted, as hoped for by this code.
But if I attempt to remove a fake name from the namepass table, the process continues, and the fake name appears to have been deleted, whether or not the name and its other 2 column values are in the table.
I think I could count rows, before and after, and use the result to confirm, or could search the rows for the name after the query, but is simpler row deletion confirmation available?
Thanks for your advice.

@mysql_connect($hostname, $user, $password) or die("can't connect");
$d="delete from namepass where name='$name'";
$z=@mysql_db_query("taupocom_taupo",$d) or die("can't delete");
echo &quot;scalar z is &quot;.$z.&quot;<br>&quot;;
echo $name.&quot; and his or her password were deleted from the namepass table<br>&quot;;
 
hello

why dont you use mysql_affected_rows()

it returns number of rows affected for insert,delete or update queries.

so

if (mysql_affected_rows > 0) {

echo &quot;record deleted&quot; ;
}
else {
echo &quot;no matching record found&quot; ;
}


spookie
 
mysql_affected_rows() was exactly the method I needed.
Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top