I’ve taken a bit of a memcache script that i’ve used previously without issue, but on the new page, I don’t get any response.
the memcache is in a function which is included from another page. what I do is put the md5 hash the mysql query and store that as the key for the memcached data. if the key isn’t in memcache, then I go, create the data, put it into memcache and return it.
I think the code is fairly simple. Here are the important bits (it’s a large page creating the output, so you don’t need all that, though the ‘return’ I think is important as I fear that might be where I’m screwing up.
I call the function with
$outList.= outData($getList);
where $getList is a mysql query
The $outList function is
<?php @$memcache = new Memcache; @$memcache->connect('localhost',11211); function outData($getList) { $memVal = @$memcache->get(MD5($getList)); if($memVal=='') { $results=mysql_query($getList)or die(mysql_error()); // then I do a bunch of stuff with the data @$memcache->set(MD5($getList), $memVal, false, 60000); } return $memVal; }
I can display all the stuff to create $memVal, but i suspect the error is in the if line, but the same code is used on another page without issues.
Anything look wrong with this?
with all those @’s suppressing errors, there’s no way to know what is failing.
I ran it – sans the @’s and the answer popped right up though – on the line:
Where does it get the variable $memcache ? It’s not passed into the function.