jeeva Posted February 16, 2007 Share Posted February 16, 2007 hi frnds, i have used Php and Ms Access in my application.Now i want fetch the number of rows from the user master table. For this i have used odbc_num_rows but its gives -1 whether its 0 or whatever.i don't know y my code is $chk=odbc_num_rows(odbc_exec($php121db,"select * from UserMaster where uname='$username' and password='$password'")) or die(odbc_errormsg()); echo "check value--".$chk; if($chk>0) echo "vlaid Login"; else echo "Invalid Login"; Can u please tell me wts up? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 16, 2007 Share Posted February 16, 2007 You have the or die() in the wrong set of parenthesis (and I think one too many?). Seperate this all out until you know what it's doing better. What you have looks like this: $ex = odbc_exec($php121db,"select * from UserMaster where uname='$username' and password='$password'"); $chk=odbc_num_rows($ex) or die(odbc_errormsg(); You want: $ex = odbc_exec($php121db,"select * from UserMaster where uname='$username' and password='$password'") or die(odbc_errormsg(); $chk=odbc_num_rows($ex) Also, read the article in my signature called how to ask questions - your title doesn't say anything about the problem... Quote Link to comment Share on other sites More sharing options...
jeeva Posted February 16, 2007 Author Share Posted February 16, 2007 i have seperated like that also, but its gives the same -1 Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 16, 2007 Share Posted February 16, 2007 and you don't get an error? If you look at the manual it says that means there was an error. Try just printing the odbc_errormsg after the query. Quote Link to comment Share on other sites More sharing options...
craygo Posted February 16, 2007 Share Posted February 16, 2007 read the site on odbc_num_rows, I remember reading about some glitch it has. Go to the php.net site and read up on it. try using COUNT() instead. Ray Quote Link to comment Share on other sites More sharing options...
jeeva Posted February 16, 2007 Author Share Posted February 16, 2007 i have printed that error but its says nothing Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.