Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8228131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:21:39+00:00 2026-06-07T16:21:39+00:00

I have what I thought was a straight-forward query, but I cant seem to

  • 0

I have what I thought was a straight-forward query, but I cant seem to get it to work. All help appreciated!

The Tables:

There are two tables involved: gallery_meta and prm_album. The gallery_meta tbl contains the data for images stored in the file structure. The prm_album tbl simply aligns album ID’s with album regular-text Names. For both tbls, the field names used in the query are correct.

The Query:

In the code below, I first get an array of saved album names. I then check the file structure to see which directories actually contain images. At this point I want to query the db again for a thumbnail for each of the albums that return as positives. It is here that the the process fails.

All I get is a whitescreen, no error reporting whatsoever. The array $albums is being filled successfully, and the $id variable is being passed to the $q query. $pattern is simply the file path to the parent directory where the album directories are stored.

            //Get album names from db
            $albums = array(); 
            $q="SELECT ID, Name FROM prm_album WHERE 1";
            $sql=mysql_query($q) or die(mysql_error());
            while($r=mysql_fetch_array($sql)) {
                $album = $r['Name'];
                $album_dir = $pattern.$album.'/';

                //check which albums actually contain images (dividing to account for thumbs, med, lrg.)
                $filecount = count(glob($album_dir.'*'))/3;

                //if images found, put album in array
                if($filecount >= 1) {
                    $albums[ $r['ID'] ] = $filecount;
                }
            }

            foreach($albums as $id => $filecount) {     
                $q="SELECT m.AlbumID, m.FileName, m.FileExt,
                        m.LegacyName, m.IsDefault,
                        p.Name
                        FROM gallery_meta AS m
                            LEFT JOIN prm_album AS p
                                ON m.AlbumID = p.ID

                        WHERE m.AlbumID = $id
                            AND Public = 1
                            ORDER BY IsDefault DESC
                            LIMIT 0,1";

                $sql=mysql_query($q) or die(mysql_error());
                while($r=mysql_fetch_array($sql)) {
                    $album=$r['Name'].'/';
                    $legacyname=$r['LegacyName'];
                    $filename=$r['FileName'].'-sm.';
                    $ext=$r['FileExt'];

                    echo '<img src="'$pattern.$album.$filename.$ext.'" />'.$legacyname.'<br/>';
                }
            }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:21:41+00:00Added an answer on June 7, 2026 at 4:21 pm

    Change

    echo '<img src="'$pattern.$album.$filename.$ext.'" />'.$legacyname.'<br/>';
    

    to

    echo '<img src="'.$pattern.$album.$filename.$ext.'" />'.$legacyname.'<br/>';
    

    The first dot was missing. And always set these lines on top of your script =)

    ini_set('display_errors', 1);
    error_reporting(E_ALL);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would have thought this straight forward, but it doesn't seem the case. Aim:
I have, what I thought was a pretty straight-forward query. In normal Sql this
Thought this would be pretty straight forward, but my value is remaining the same
So i thought this would be straight forward but i keep getting compile errors,
I thought this was going to be straight forward but I managed to hose
I have a very straight forward select query such as this: SELECT * FROM
I have a simple SQL question, I thought it would be quite straight forward
I'm new to AutoFac, but I thought this would be pretty straight forward. I've
I would have thought this one would be simple but I'm trying to change
I would have thought that this would be an easy thing to do, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.