jonathonoss
MIS
I am having trouble taking a variable obtained from SQL2000, and using it as part of the directory path for an opendir() statement.
Here is the code:
while(odbc_fetch_row($cmservicelistr))
{
$cmnumber = odbc_result($cmservicelistr, 1);
$medreccountq = "select count([logmemo]) from caselogdata where (([clogcase] = $cmnumber) and (medreclink is not null))";
$medreccountr = odbc_exec($connect, $medreccountq);
$medreccount[$lt][0] = odbc_result($medreccountr,1);
$medreccount[$lt][1] = $cmnumber;
/////////////////////////////////////////////////////////
//Check to see how may CM files are in the File Directory
/////////////////////////////////////////////////////////
// $dirsearch = "cm/" . intval($cmnumber) . "/";
// $dirsearch = "cm/" . strval($cmnumber) . "/";
// $dirsearch = "cm/" . $cmnumber . "/";
// $dirsearch = "cm/$cmnumber/";
// $dirsearch = ("cm/" . $medreccount[$lt][1] . "/");
$dirsearch = ("cm/" . 41659 . "/");
echo $cmnumber . " ";
//Identify files in PATH provided by $dirsearch
$dh = opendir($dirsearch);
while (false !== ($filename = readdir($dh))) {
$files[] = $filename;}
//Track number of files per CM#
$filescountarray[] = count($files)-2;
unset($files);
$lt++;
}
The code as shown here works. I have a loop. It gets each CM# in a query (not shown) by "$cmnumber = odbc_result($cmservicelistr, 1);" Then I take each CM# in the loop, and use it as part of a directory path to total the number of files in the directory with "$filescountarray[] = count($files)-2;".
The problem is how I take the CM# and use it as part of the directory path, as in "$dh = opendir($dirsearch);". The current code use for $dirsearch = '$dirsearch = ("cm/" . 41659 . "/");' works because I plug in 41659 (one of the CM#'s). But if I use one of the other "$dirsearch =" lines to incorporate the $cmnumber variable, it fails. Yet the line 'echo $cmnumber . " ";' prints each cmnumber correctly. And the lines earlier that use $cmnumber, such as "$medreccountq = ..." and "$medreccount[$lt][1] = $cmnumber;" work fine. Why does $cmnumber work fine for the other statements, but not opendir()?
The error I get is not even a statement telling me which line has the error, like a typical PHP error. I either get the "Page can not be displayed" HTTP error. Or I get the "Internet Explorer cannot open the Internet site then below "The server returned an invalid or unrecognized response." In the IIS log, the IIS server issues a status of 200 by each request of this page, not indicating a problem at that end.
I installed SQL 2000 on a separate W2K Server box and installed PHP using PHP.EXE to parse .PHP extensions, to see if the error would go away on a different machine, but it does not.
Is this a PHP coding error?
Thanks,
Jon
Here is the code:
while(odbc_fetch_row($cmservicelistr))
{
$cmnumber = odbc_result($cmservicelistr, 1);
$medreccountq = "select count([logmemo]) from caselogdata where (([clogcase] = $cmnumber) and (medreclink is not null))";
$medreccountr = odbc_exec($connect, $medreccountq);
$medreccount[$lt][0] = odbc_result($medreccountr,1);
$medreccount[$lt][1] = $cmnumber;
/////////////////////////////////////////////////////////
//Check to see how may CM files are in the File Directory
/////////////////////////////////////////////////////////
// $dirsearch = "cm/" . intval($cmnumber) . "/";
// $dirsearch = "cm/" . strval($cmnumber) . "/";
// $dirsearch = "cm/" . $cmnumber . "/";
// $dirsearch = "cm/$cmnumber/";
// $dirsearch = ("cm/" . $medreccount[$lt][1] . "/");
$dirsearch = ("cm/" . 41659 . "/");
echo $cmnumber . " ";
//Identify files in PATH provided by $dirsearch
$dh = opendir($dirsearch);
while (false !== ($filename = readdir($dh))) {
$files[] = $filename;}
//Track number of files per CM#
$filescountarray[] = count($files)-2;
unset($files);
$lt++;
}
The code as shown here works. I have a loop. It gets each CM# in a query (not shown) by "$cmnumber = odbc_result($cmservicelistr, 1);" Then I take each CM# in the loop, and use it as part of a directory path to total the number of files in the directory with "$filescountarray[] = count($files)-2;".
The problem is how I take the CM# and use it as part of the directory path, as in "$dh = opendir($dirsearch);". The current code use for $dirsearch = '$dirsearch = ("cm/" . 41659 . "/");' works because I plug in 41659 (one of the CM#'s). But if I use one of the other "$dirsearch =" lines to incorporate the $cmnumber variable, it fails. Yet the line 'echo $cmnumber . " ";' prints each cmnumber correctly. And the lines earlier that use $cmnumber, such as "$medreccountq = ..." and "$medreccount[$lt][1] = $cmnumber;" work fine. Why does $cmnumber work fine for the other statements, but not opendir()?
The error I get is not even a statement telling me which line has the error, like a typical PHP error. I either get the "Page can not be displayed" HTTP error. Or I get the "Internet Explorer cannot open the Internet site then below "The server returned an invalid or unrecognized response." In the IIS log, the IIS server issues a status of 200 by each request of this page, not indicating a problem at that end.
I installed SQL 2000 on a separate W2K Server box and installed PHP using PHP.EXE to parse .PHP extensions, to see if the error would go away on a different machine, but it does not.
Is this a PHP coding error?
Thanks,
Jon