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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 03:01:27 2024 UTC