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
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ahmed at nmt dot edu
New email:
PHP Version: OS:

 

 [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-2021 The PHP Group
All rights reserved.
Last updated: Sat Nov 27 15:03:28 2021 UTC