Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jun 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Showing the number of files in a directory -- error with my code

    I am using the following code to show the number of files in a directory :

    PHP Code:
    $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 :

    PHP 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

  • #2
    Super Moderator Inigoesdr's Avatar
    Join Date
    Mar 2007
    Location
    Florida, USA
    Posts
    3,642
    Thanks
    2
    Thanked 405 Times in 397 Posts
    You need to use double-quotes to parse the string for variables, or concatenate the string:
    PHP Code:
    $path "/gallery/$series/";
    // or
    $path '/gallery/' $series '/'

  • #3
    New Coder
    Join Date
    Jun 2007
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    Hmm, still not working. Here is the full code, perhaps somebody can help me? I probably should have posted this first. Silly me --

    PHP Code:
    <?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';
    ?>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •