SitePoint Sponsor |
|
User Tag List
Results 1 to 8 of 8
-
Jan 15, 2005, 19:55 #1
- Join Date
- Oct 2004
- Location
- nigeria
- Posts
- 151
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
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");
}
?>
-
Jan 15, 2005, 20:02 #2
- Join Date
- Dec 2003
- Location
- Federal Way, Washington (USA)
- Posts
- 1,524
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You'll need to change this:
Code:$row_num=odbc_fetch_row($result);
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
-
Jan 15, 2005, 21:33 #3
- 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
-
Jan 15, 2005, 21:35 #4
- Join Date
- Jul 2004
- Location
- canada
- Posts
- 3,193
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
i think he meant
odbc_num_rows()
-
Jan 15, 2005, 21:39 #5
- Join Date
- May 2003
- Location
- Washington, DC
- Posts
- 10,653
- 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.
-
Jan 15, 2005, 21:49 #6
- Join Date
- Oct 2004
- Location
- nigeria
- Posts
- 151
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
have got the solution odbc_num_rows($result);
-
Jan 17, 2005, 02:40 #7
- 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.
-
Jan 17, 2005, 08:35 #8
- Join Date
- Dec 2003
- Location
- Federal Way, Washington (USA)
- Posts
- 1,524
- 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.
the number of rows available after a SELECT will return
-1 with many drivers.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