php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #9734 Error
Submitted: 2001-03-13 21:42 UTC Modified: 2001-04-25 18:52 UTC
From: ahmed at nmt dot edu Assigned:
Status: Not a bug Package: MySQL related
PHP Version: 4.0.4pl1 OS: Unix
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
39 + 23 = ?
Subscribe to this entry?

 
 [2001-03-13 21:42 UTC] ahmed at nmt dot edu
It seems like the DELETE query don't return any error so I have to test first for the existing of the element than if exist I'll delete it.


$db = mysql_connect("localhost", "root");
mysql_select_db("MY_DBASE", $db);
$Query="SELECT * FROM  MY_DATA WHERE MY_DATA.id=$id";
$result = mysql_query($Query, $db);
$rows = mysql_num_rows($result);
if ($rows>0) {
           $Query="DELETE FROM  MY_DATA WHERE MY_DATA.id=$id";
           mysql_query($Query, $db);
           print("<P align=center><font size=6 face=italic><strong>Recored 
                  $id deleted</strong></font>\n"); 
        }
else { 
           printf ("<P align=center><font size=6 face=italic><strong>
                      Error deleting record!:</strong> %s</font>\n", 
                      mysql_error ());
        }



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-04-25 18:52 UTC] cynic@php.net
watch this:

mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| foo            |
+----------------+
1 row in set (0.00 sec)

mysql> select * from foo;
+--------------+
| bar          |
+--------------+
| 999999999.99 |
+--------------+
1 row in set (0.00 sec)

mysql> delete from foo where bar = 'hello';
Query OK, 0 rows affected (0.00 sec)

mysql>

the truth is that delete of 0 rows is NOT an error.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 23:01:34 2024 UTC