Page 1 of 1

Problem with cache in file_exists() function

Posted: Thu Oct 21, 2004 7:44 am
by InSion
Hi, I'm looking if some files exists and if they don't, I create them manually (they're flash files). The problem is that after uploading them, they are still being shown as inexistant files... After some headache I found that there could be a cache problem, I tried using clearstatcahce() but probably I'm using it worng :?: . Here is the relevant part of the code:

Code: Select all

<?php
    #Show the result in a table
      	while ($row=mysql_fetch_array($result)) {
		    if ($row["IDalojamiento"] < 10) { $numero = '00'.$row["IDalojamiento"]; }
		    elseif ($row["IDalojamiento"] < 100) { $numero = '0'.$row["IDalojamiento"]; }
		    else { $numero = $row["IDalojamiento"]; }
	      if (!(file_exists($root.'alojamientos/pel/alo'.$numero.'.swf'))) {
			echo '<tr>';
        	echo '<td align="center" class="labelcell">';if ($row["alta"] == 1) { echo '*'; }
			echo '</td>';
			echo '<td align="center" class="labelcell">'.$row["IDalojamiento"].'</td>';
			echo '<td align="left" class="labelcell">'.$row["nombre"].'</td>';
			echo '<td align="left" class="labelcell">'.$row["direccion"].'</td>';
			echo '<td align="center" class="fieldcell"><a href="contenido.php?sistema=1&seccion=modificacion&id='.$row["IDalojamiento"].'">Modificar</a></td>';
			echo '</tr>';
		  }
		  #Clear cache
		  clearstatcache();
      	}
?>
This generates a table (start and ends are out) this way:
| * | ID | name | address | Modify button |

Any help would be appreciated. Thank you very much

Posted: Thu Oct 21, 2004 8:58 am
by Weirdan
move clearstatcache before file_exist. this way you will always have fresh data.

Posted: Thu Oct 21, 2004 9:03 am
by InSion
That was what I did at once then I moved It after... anyway I tried again and the problem persists...

Posted: Thu Oct 21, 2004 3:52 pm
by rehfeld
why dont you try something like this:

Code: Select all

$file = $root.'alojamientos/pel/alo'.$numero.'.swf';


echo $file;

if (file_exists($file)) {
    echo 'yes';
} else {
    echo 'no';
}

before trying to see if it exists. that way YOU can SEE if it really exists or not.

the problem is likely related to relative file paths, im guessing.


feyd | use the

Code: Select all

tags![/color]

Solved

Posted: Fri Oct 22, 2004 6:40 am
by InSion
:lol: Thank you, it was a stupid problem I discovered when printing $file... $root was pointing to c:/InetPub/wwwroot/ and it should point to c:/InetPub/wwwroot1/... As the site is twice, It correctly detected the file was missing, but in the incorrect site. Thank you very much :oops:.