tapius1 Posted July 1, 2009 Share Posted July 1, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/164429-solved-help-same-code-almost-same-enviornment-different-results/ Share on other sites More sharing options...
iPixel Posted July 2, 2009 Share Posted July 2, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/164429-solved-help-same-code-almost-same-enviornment-different-results/#findComment-867857 Share on other sites More sharing options...
tapius1 Posted July 4, 2009 Author Share Posted July 4, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/164429-solved-help-same-code-almost-same-enviornment-different-results/#findComment-868660 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.