Jump to content

ODBC_NUM_ROWS


tapius1

Recommended Posts

so i finnally found the source of a lot of frustration:

$count = odbc_num_rows($rs) .,, always returns -1 on my CentOS / DB2 box but on windows it returns the actual row count, could someone help me modify my code so that it gets the actual row count?

<?php
//Establish connection to database

$ctrl_num = $_POST['ctrl_num'];
$ssn_num = $_POST['ssn_num'];

$host = "acq";
$conn = odbc_connect ("DB2CONN","michaele", "********");
$query = "Select * from KCWEB WHERE WCTRL =$ctrl_num AND SSN_NUM=$ssn_num";
//Execute query
$result = odbc_exec($conn, $query) ;
$firstname = odbc_result($result, 'fname'); 
$count = odbc_num_rows($result);
if ($count==1){
    print 'success! - logged in';
    //if successful
print("<td>$firstname has logged in. Welcome to the payment center</td>\n"); 
}else {
    //failed login
echo "<br>Incorrect Control Number OR Social Security Number Found</br>"; 
echo "<br>Tried to execute the following query:Select * from KCWEB WHERE WCTRL =$ctrl_num AND SSN_NUM=$ssn_num </br>";
echo "<left><br><input type='button' value='Retry' onClick='history.go(-1)'></left>";
}

?>

Thanks, your help is very much appriciated

Link to comment
https://forums.phpfreaks.com/topic/164528-odbc_num_rows/
Share on other sites

oh YES, I remember that problem now. you should just be able to skip the num rows part:

 

<?php
//Establish connection to database

$ctrl_num = $_POST['ctrl_num'];
$ssn_num = $_POST['ssn_num'];

$host = "acq";
$conn = odbc_connect ("DB2CONN","michaele", "********");
$query = "Select * from KCWEB WHERE WCTRL =$ctrl_num AND SSN_NUM=$ssn_num";
//Execute query
$result = odbc_exec($conn, $query) ;
if($firstname = odbc_result($result, 'fname')){
    print 'success! - logged in';
    //if successful
    print("<td>$firstname has logged in. Welcome to the payment center</td>\n"); 
}else {
    //failed login
    echo "<br>Incorrect Control Number OR Social Security Number Found</br>"; 
    echo "<br>Tried to execute the following query:Select * from KCWEB WHERE WCTRL =$ctrl_num AND SSN_NUM=$ssn_num </br>";
    echo "<left><br><input type='button' value='Retry' onClick='history.go(-1)'></left>";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/164528-odbc_num_rows/#findComment-867814
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.