Jump to content

[SOLVED] HELP!! SAME CODE (ALMOST) SAME ENVIORNMENT DIFFERENT RESULTS!


Recommended Posts

I work on a windowsXP with ODBC running with a DSN to a DB2 server (AS/400) everything connects fine with my php code in windows and when i query the server to see if a user name and password exist, it returns me with a success or fail and retrieves the user's first name if successful. The same code is supposed to run on a CentOS(RED HAT) machine with the same ODBC extensions (running Zend Server) and iSeries Access Driver for DB2 (on the AS/400). I'm able to get php code to run and connect, query, and return results.  However for some reason passing (the correct values) variables always leads to a failed login on the CentOS Machine, despite successful runs of other php scripts. I think the problem lies somewhere in getting the result back.. ive added a bunch of extra echo statements to help me figure what is going on here. the echos state the query and show it to be correct, so why don't i see results?

Here is the code for logincheck.php :

<?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>";
}

?>

 

 

the code for the html login.html I'm not including because it is trivial, its a form with 2 textboxes one is a password box, and a submit button..

anyway some help or possible answer as to why this only works from the windows machine, when they are both using the same code and both make use of ODBC and the DSN

---would greatly appreciate any help thanks

Link to comment
Share on other sites

Are you sure that the driver you are using "iSeries Access Driver for DB2 " is reliable. I've had a similar issue where nothing was working purely because the Microsoft ODBC driver for oracle i was using was utterly useless, and i had to move to the driver provided by oracle itself. Can you test a query and see if any results get returned just to prove that the drivers are working properly on ur centOS?

Link to comment
Share on other sites

I figured out the problem! this issue was caused by the odbc_num_rows() function. on the DB2 iSeries driver it didn't function. Always out put -1, so a solution was write a new get_num_rows() function to manually loop the rows. Google actually heh. but it's worth bringing up for anyone else who has had this issue and didn't notice where it the value was always incorrect.

Link to comment
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.