I reall don't understand
I've set up this simple test file (and it works):
PHP Code:
include('../dbconnect.php'); //handles db connection
include('../phpcache.php');
if (!($et=cache_all(30))) {
$sql=mysql_query("SELECT MAX(ID) FROM Photos");
$res=mysql_fetch_array($sql);
$total=$res["MAX(ID)"];
echo 'Max ID inside of cache:'. $total.'<br>';
cache_variable("total");
endcache();}
echo 'Max ID outside of cache:'. $total.'<br>';
It outputs the correct values
BUT
I have a functions.php file that I use in my website, and inside one of the functions there's this line of code:
PHP Code:
if (!($et=cache_all(30))) {
$sql=mysql_query("SELECT MAX(ID) FROM Photos");
$res=mysql_fetch_array($sql);
$total=$res["MAX(ID)"];
cache_variable("total");
endcache();}
which is basically the same...BUT...$total is NULL outside of the cache (e.g. after this code)
Could anyone explain why on earth the same code produces 2 different results? I'm guessing it's because of variable scope but I really don't see how it would apply here, since we're inside the function already
PS yes, I am including phpcache.php inside the function :P
Bookmarks