PDA

View Full Version : phpcache problems



qwhat
01-29-2008, 09:37 AM
Hi,
This is my first post. You kindly said in the last paragraph of your tutorial :
http://www.websitepublisher.net/article/phpcache/ that if I didn't understand to get in touch through the forum. So here I am.

I downloaded and I tried implementing the phpCache.inc script but it doesn't seem to help. I verified the /tmp/cache/ directory that I created but there isn't anything in there and I do have some slow reaction time at certain pages (which is why I would like to implement this).
You can see examples of the pages at :
http://www.casart.fr/2008/corby/works.php?page=1 and the following pages (where I implemented the code).
This php script, connecteng.php, is used as an include in the works.php page and the catalogue.php page.
I've never written PHP and I try to understand how it's done through forums and tutorials, so there is probably some very pretty ugly coding.
If someone can help me use the script, I really would appreciate it.

Here's my code :

<?php
include("../phpCache.php");
$et=cache_all(180);

$db = mysql_connect("localhost", "root", "password");
mysql_select_db("mysql",$db);

$sqlNum = 'SELECT * FROM corby WHERE cata=1 ORDER BY engname';

$sql = 'SELECT engname, little, big, engleg , engtittle, cata FROM corby WHERE cata=1 ORDER BY engname LIMIT '.(($page-1)).",".(1);

$resultNum = mysql_query($sqlNum);

$numRows = mysql_num_rows($resultNum);

$sqlnext = 'SELECT little, cata FROM corby WHERE cata=1 ORDER BY engname LIMIT ' .(($page)).",".(1);
$sqlpre = 'SELECT little, cata FROM corby WHERE cata=1 ORDER BY engname LIMIT ' .(($page-2)).",".(1);

//sommaire
$req = 'SELECT * FROM corby WHERE cata=1 ORDER BY engname ';
$result = mysql_query($req);
$result1 = mysql_num_rows($result);
$milieu = $result1 / 2;
$mil = (int)$milieu ;
$left = 'SELECT * FROM corby WHERE cata=1 ORDER BY `engname` ASC LIMIT 0,'.($mil);
$right = 'SELECT * FROM corby WHERE cata=1 ORDER BY `engname` ASC LIMIT '.($mil).",".($result1);

$authors = array(); // create the array
// extract the query data into array $main
while ($main = mysql_fetch_array($resultNum)){
// use array push to insert a result set row into our array
array_push($authors, $main);
}
cache_variable("authors"); // cache your array
mysql_free_result($resultNum);

endcache();

?>

Chris
01-29-2008, 12:52 PM
Did you set the correct permissions on the tmp directory?

qwhat
01-29-2008, 03:07 PM
I'm not sure, but I believe so. Permissions are set at 757.

Chris
01-29-2008, 03:17 PM
try 777, it needs execute permissions as well so it can make files and 757 may be messing it up.

the cache directory too