Checking record has been deleted?

Posted on 2006-04-08
Last Modified: 2013-12-12
Im deleting records and wnating to check it has been deleted to direct to another page or show error if not. Im using ODBC so i cant use the simple mysql_affected_rows and odbc_affected_rows doesnt seem to be working. A sample of what im wanting to do is below. Is any other way around it?


if(odbc_affected_rows() == 1){
'do something'
} else {
'something else'
Question by:generali
    LVL 142

    Expert Comment

    by:Guy Hengel [angelIII / a3]

    if(odbc_num_rows() > 0){
    'do something, row(s) delete'
    } else {
    'something else'
    LVL 2

    Author Comment

    I tried that and it returns an error saying wrong parameter count. I forgot to mention my DB is access and i think that odbc_num_rows() returns -1 for access. So with that ill never meet the true criteria. Is there another way i can check if record has been deleted/updated?

    LVL 2

    Author Comment

    Just thought i'd add the delete that i checked the above on does actually work on only one row, so the desired result from the odbc_num_rows() should have been 1.
    LVL 142

    Accepted Solution

    you have to pass the result handle of the delete operation:

    $query = "DELETE ... ";
    $result = odbc_exec($dbc, $query);
    $rows_affected = odbc_num_rows($result);

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    php hash passwords 2 27
    PHP Radio Array 4 27
    Where is this Code Igniter page going? 4 24
    PHP foreach DB query 4 21
    Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
    Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now