0

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/

???

2
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by colweb
0

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;
0

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".

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.