Web Hosting Talk







View Full Version : strange !!! help


Badie
09-19-2006, 11:23 AM
hi
im reading from txt file and from Excel file , i read one line from excel and compare it with all list in the txt file

this part of the code


for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++)
{
$fh = fopen($myFile, 'r');
$temp2= $data->sheets[0]['cells'][$i][1] ;

$theData = fgets($fh);

do {

if ($theData == $temp2)
echo $theData . " ->>>>> " . $temp2 . "<br>" ;


}while ($theData = fgets($fh));


everything work fine , but the if statment gives always false . i remove the if statmen and its give the result and write all the data !!
can anyone help ?

Oshaka
09-19-2006, 05:44 PM
Not really sure what you mean. But from glancing I see your "do" statement is pretty much useless.

Try


for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++)
{
$fh = fopen($myFile, 'r');
$temp2= $data->sheets[0]['cells'][$i][1] ;

$theData = fgets($fh);


if ($theData == $temp2)
{
echo $theData . " ->>>>> " . $temp2 . "<br>" ;
}
else {
while ($theData = fgets($fh));
}
}

Wim Conradie
09-26-2006, 04:59 PM
Maybe you should trim the data variables from 'invisble' characters (like tabs, spaces, end of line, cariage return, etc.), because you won't see them in the debugging echo part of your script.