|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-04-23 19:52 UTC] jarod dot ferguson at eds dot com
I would like to apologize, for I have uninstalled 4.2 from my server and went back to 4.1, and now I do not have the complete error messages.
Server: Windows 2000 IIS
SQL server 2k
PHP ver 4.2
odbc
Problem: Old scripts that ran fine on version 4.1.2 now give error messages stating that the odbc connection is in use "SQLstate S1000 waiting for result from previous hstmnt"
We have scoured the INI, tried the old ini as well. same results. I put 4.1.2 back on, issue is gone.
I am running into this issue when looping through the Db and running a subloop inside based off results from the first loop. I do this with functions inside a loop as well as actually running a new while loop inside of the first one. I have tried altering my code, making sure i have closed all db connections (which i never do) and free allodbc results from memory.
sample codes:
here are the defined functions:
function countapproved ($project_id){
$time = date ("H:i");
$date = date("m/d/y");
$cto_f = odbc_connect("emp1","","")
or die("Error Connecting To CDBMS.");
$cnt_rec = ("select count (*) from [cto_main] where emp_pro ='$project_id' and date = '$date' and pref_time < '$time' and cto_status_id <> '2' and cto_status_id <> '3' and (shift_time > '$time')");
$ex_cr = odbc_exec($cto_f,$cnt_rec);
$count = odbc_result($ex_cr, 1);
return $count;
}
function countgranted ($project_id){
$time = date ("H:i");
$date = date("m/d/y");
$cto_f = odbc_connect("emp1","","")
or die("Error Connecting To CDBMS.");
$cnt_rec = ("select count (*) from [cto_main] where emp_pro ='$project_id' and date = '$date' and cto_status_id = '2'");
$ex_cr = odbc_exec($cto_f,$cnt_rec);
$count = odbc_result($ex_cr, 1);
return $count;
}
function countsignedout ($project_id){
$time = date ("H:i");
$date = date("m/d/y");
$cto_f = odbc_connect("emp1","","")
or die("Error Connecting To CDBMS.");
$cnt_rec = ("select count (*) from [cto_main] where (emp_pro ='$project_id') and (date = '$date') and cto_status_id = '3'");
$ex_cr = odbc_exec($cto_f,$cnt_rec);
$count = odbc_result($ex_cr, 1);
return $count;
}
function countpending ($project_id){
$time = date ("H:i");
$date = date("m/d/y");
$cto_f = odbc_connect("emp1","","")
or die("Error Connecting To CDBMS.");
$cnt_rec = ("select count (*) from [cto_main] where emp_pro ='$project_id' and date = '$date' and pref_time > '$time' and cto_status_id <> '2' and cto_status_id <> '3' and (shift_time > '$time')");
$ex_cr = odbc_exec($cto_f,$cnt_rec);
$count = odbc_result($ex_cr, 1);
return $count;
}
running inside this loop:
$get_cto_pro= ("SELECT *, project.project_name FROM cto_project INNER JOIN project ON cto_project.cto_project_id = project.project_id order by project_name");
$ex_cp = odbc_exec($cto,$get_cto_pro);
$row = 0;
while( odbc_fetch_row( $ex_cp ) ) {
$row++;
$p_name= odbc_result( $ex_cp, 'project_name' );
$project_id= odbc_result( $ex_cp, 'cto_project_id' );
$total_appr = countapproved ($project_id);
$total_granted = countgranted ($project_id);
$total_s_o = countsignedout ($project_id);
$total_pend = countpending ($project_id);
$total = $total_appr + $total_granted + $total_s_o + $total_pend;
print ("<tr><td><a href=\"queue.php?p_name=$p_name&project_id=$project_id\">$p_name</td><td bgcolor=ffffff><center>$total</center></td><td bgcolor=ffffff><center>$total_appr</center></td><td bgcolor=ffffff><center>$total_pend</center></td><td bgcolor=ffffff><center>$total_granted</center></td><td bgcolor=ffffff><center>$total_s_o</center></td></tr>");
I may just be doing something wrong, but I have had very good performance untill now. Any feedback would be appreciative.
Thanks.
Jarod Ferguson
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 21 05:00:01 2025 UTC |
a simplified example would be : $res=odbc_exec($conn,"select * from categorii order by ordine_categorie"); for($i=1;odbc_fetch_row($res);$i++) { $res2=odbc_exec($conn,"select * from subcategorii where id_categorie=$idcateg order by ordine_subcategorie"); ...... } the second query fails but ONLY when the first return more than one row. i tried with different connections but doesn't work. check my original post at http://news.php.net/article.php?group=php.db&article=18880OK, simple version: $var = odbc_exec($cnx,Some query); $row = 0; while (odbc_fetch_row($var)){ $row++; $res1 = odbc_fetch_row($var, 1 ); $res2 = odbc_fetch_row($var, 2 ); $var2 = odbc_exec($cnx,Select * from some table where field = $res1); while (odbc_fetch_row($var2)){ $row++; $res3 = odbc_fetch_row($var2, 1 ); $res4 = odbc_fetch_row($var2, 2 ); } }