SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot asmictech's Avatar
    Join Date
    Oct 2004
    Location
    nigeria
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question DISPLAY NUMBER OF AFFECTED ROWS(odbc_?)

    Dear folks,
    pls help me out.
    i have written a code to change password. it works perfectly i.e. sql query "update is ok", now i want to display number of affected rows that i can inform user if password is changed or not. here is my code pls help out.
    i could find which property to use.
    using php to connect to ms access(dsn connection).



    here is my code


    Quote:
    <?php

    Class changepin {
    function changepin($oldpwd,$newpwd,$cnewpwd){
    $this->oldpwd=$oldpwd;
    $this->newpwd=$newpwd;
    $this->cnewpwd=$cnewpwd;

    //echo "submitted values:".$uid,$pwd;
    if(isset($oldpwd)&&isset($newpwd)&&isset($cnewpwd)){
    require_once "conn.php";
    session_start();
    $uid=$_SESSION['uid'];
    $query="update biodata set pwd='$newpwd' where uid='$uid'";
    if(!odbc_exec($connect,$query)){echo "Error executing query:".$query;}
    else{$result=odbc_exec($connect,$query);}
    $row_num=odbc_fetch_row($result);
    echo $row_num;
    if($row_num==0){
    echo "Failed";}
    else{session_start();
    $_SESSION['uid']=$uid;
    echo "Successful"; }//end inner if statement
    odbc_close($connect);
    }//close of outer if
    }//close method
    }//close class

    if((isset($_POST['oldpwd'])&&isset($_POST['newpwd'])&&isset($_POST['cnewpwd']))&&($_POST['newpwd']=$_POST['cnewpwd'])){
    $oldpwd=$_POST['oldpwd'];
    $newpwd=$_POST['newpwd'];
    $cnewpwd=$_POST['cnewpwd'];

    new changepin($oldpwd,$newpwd,$cnewpwd);
    }// close of if statement
    else{
    header("location: changepin.php");
    }
    ?>
    Success is achieved and maintained by those who keep trying.

    www.ngportal.net

  2. #2
    $this->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Dec 2003
    Location
    Federal Way, Washington (USA)
    Posts
    1,526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You'll need to change this:

    Code:
    $row_num=odbc_fetch_row($result);
    to this:

    Code:
    $row_num=mysql_num_rows($result);
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    Showcase your music collection on the Web

  3. #3
    SitePoint Zealot asmictech's Avatar
    Join Date
    Oct 2004
    Location
    nigeria
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    am not using mysql database mind u. it is ms access
    Success is achieved and maintained by those who keep trying.

    www.ngportal.net

  4. #4
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think he meant
    odbc_num_rows()

  5. #5
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,576
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Note that Access does not implement odbc_num_rows() correctly, at least on selects. But IIRC it does work for update/insert/delete.

    Also note that there is huge potential for scalability issues with access.

  6. #6
    SitePoint Zealot asmictech's Avatar
    Join Date
    Oct 2004
    Location
    nigeria
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    have got the solution odbc_num_rows($result);
    Success is achieved and maintained by those who keep trying.

    www.ngportal.net

  7. #7
    SitePoint Zealot asmictech's Avatar
    Join Date
    Oct 2004
    Location
    nigeria
    Posts
    151
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it didn't work well. pls help me out. odbc_num_rows($result) keeps displaying 1 when the update isn't done likewise when done. so i can't get the actual result. pls help out on the function that will work best.
    Success is achieved and maintained by those who keep trying.

    www.ngportal.net

  8. #8
    $this->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Dec 2003
    Location
    Federal Way, Washington (USA)
    Posts
    1,526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    From a prior post (yeah, that's the ASP forum):

    You get a -1 if a record count is unavailable.
    and also from the PHP manual:

    the number of rows available after a SELECT will return
    -1 with many drivers.
    But all is not lost. There are several tips and tricks in the manual which should help you get the results you want.
    Last edited by vinyl-junkie; Jan 17, 2005 at 08:40. Reason: expanded on my thoughts a bit
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    Showcase your music collection on the Web


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •