for some reason, the exact same code without the added "$i[id]" part is working somewhere else on my site, but this is just rediculously NOT working for what i have here:

function nimg($directory='.')
{return count(glob($directory."/item/".$i[id]."/*"));};

i tried this code when there was no item directory made yet and still when i did this:

echo nimg();

it outputted the number 1. which is right off the bat WRONG.

now i decided to mak the actual directory "item"
and $i[id] in this case equals the number: 55

now i made the directory inside the "item" directory called "55"

still echos 1 when there is obviously 0 images in there.
i added an image. still echod 1.
then i added a 2nd image.
the darn thing still echos "1"

help me please.

just for references..
the directory the code is coming from is:
http://www.mysite.com/purchase/item.php

the directory it needs to count images in(int this case):
http://www.mysite.com/purchase/item/55/

???

i found the code!
somewhere online and added the freakin document root thing cause it like always works best.

$directory = $_SERVER[DOCUMENT_ROOT]."/purchase/item/".$i[id]."/";
$filecount = count(glob("" . $directory . "*.png"));
echo $filecount;

Very strange indeed. What does it give if you use this:

echo count(glob("/fullpath/purchache/item/55/*"));

Replace fullpath with the complete path like "/var/www/mysite/htdocs".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.