Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.