...

View Full Version : Showing the number of files in a directory -- error with my code



allieyco
01-05-2008, 08:33 PM
I am using the following code to show the number of files in a directory :



$path = '/gallery/$series/';
print count(glob($path . '*.*'));


However, this code is showing that there are 0 files in the directory, when I know for a fact that there are more. This code is a small part of something much larger, and $series is tied to the following lines of code :



// define vars
$curCol = 0;
$series = $myrow[0];
$thumb = $myrow[1];
$gallery = $myrow[2];
$galname = $myrow[3];
$desc = $myrow[4];


Obviously, MYSQL databases are being used. If anybody could help me out here, I'd very much appreciate it :)

Allison
www.mellonin.net

Inigoesdr
01-05-2008, 08:44 PM
You need to use double-quotes to parse the string for variables, or concatenate the string:

$path = "/gallery/$series/";
// or
$path = '/gallery/' . $series . '/';

allieyco
01-05-2008, 08:53 PM
Hmm, still not working. Here is the full code, perhaps somebody can help me? I probably should have posted this first. Silly me :( --



<?php
include 'header.inc';
echo "<div id='bottom1'> <div id='bottom1p'>";
if(!isset($start)) $start = 0;
$query = "SELECT * FROM gallery_nav ORDER BY galname asc LIMIT " . $start . ", 10";
$db = mysql_connect("localhost", "allieyco_alliey", "*******");
mysql_select_db("allieyco_mellonin",$db);
$result = mysql_query("SELECT * FROM gallery_nav ",$db);
$result = mysql_query($query);
$number_of_rows = mysql_num_rows($result);

while ($myrow = mysql_fetch_array($result))
{

// define vars
$curCol = 0;
$series = $myrow[0];
$thumb = $myrow[1];
$gallery = $myrow[2];
$galname = $myrow[3];
$desc = $myrow[4];


echo "<center>";
echo "<table border=0 width=450><tr><td width=100><center>";
echo "<img src='/gallery/$series/$thumb.jpg' width=100 height=75 border=1></td><td width=10></td><td>";
echo "<div id='galdesc'>";
echo "<a href='$gallery.php'>$galname</a> </div>";
echo "<div style='padding: 5px; font-size: 10px; color: #88A71A; '>";

$path = "/gallery/$series/";
print count(glob($path . '*.*'));

echo "</div>";
echo "</td><td width=10></td><td> $desc</td><td width=10></td><td>";
echo "</table>";

$curCol++;
if($curCol > $colCount)
{// you have reached number of wanted columns
// close row, start new, and reset column counter
$curCol = 0;
}
}
echo "<hr>";
$query = "SELECT count(*) as count FROM gallery_nav";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$numrows = $row['count'];
if($start > 0)
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start - 10) .
"\"> << Previous Page </a> | \n";
if($numrows > ($start + 10))
echo "<a href=\"" . $PHP_SELF . "?start=" . ($start + 10) .
"\"> Next Page >> </a><BR>\n";
echo "<hr>";
echo "</div></div>";
include 'footer.inc';
?>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum