Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Flat File Database Image Gallery


I don't have a database available, so i'm writing an Image Gallery with
a flat file database.

I have an Add Page:
Uploads Image file, and saves $filename and $caption to text file:
captions.txt

Captions.txt is in format:
photofilename.jpg|caption to do with photo here.

I can easily read out each individual part from the captions.txt file to
display the photo and caption on a display page. I also have a delete
file that unlinks the photo, using the info in the captions.txt file,
but i can't figure out how to remove the entire line from the database
file based on the filename...??? Basically I want to click on an image
like this:
<a href=delete.php?filename=phototodelete.jpg> and have the delete.php
file unlink the picture, and then erase the line in the text file, that
begins with the filename (phototodelete.jpg).

I guess i need to search through the data file and when i match the
filename, erase the line...




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Help Debugging Flat File Picture Gallery
I have compiled some code, some written by me, some compiled from
various sources online, and basically i've got a very simple flat file
photo gallery. An upload form, to upload the photos and give them a
caption, storing the caption and filename in a text file. It's a bit
buggy when removing the photos and captions from the file, and also in
displaying them on the delete page. you can see it in action at
www.4am.com.au/gallery/upload.php - read.php - delete.php.
You can download the source at www.patoncreative.com.au/gallery.zip, and
I have posted it here below... i would appreciate some help in debugging
it.. i'm not the best with the 'foolproofing' of it before putting it
into use.

UPLOAD.PHP######################################## #

<form action="upload.php" method="post" enctype="multipart/form-data">
Select a Photo to Upload:<br>
<input type="file" name="filetoupload" size=&#3950;' class='form'><br><br>
Enter Photo Caption:<br>
<input type="text" name="caption" size=&#3950;' class='form'><br>
<input type="hidden" name="MAX_FILE_SIZE" value="<?echo $size_bytes; ?>">
<br>
<input type="Submit" value="Upload File" class='form'>
</form>

<br><br>

<?php

/* Description -----------------------------------------------------
The Super Global Variable $_FILES is used in PHP 4.x.x.
$_FILES['upload']['size'] ==> Get the Size of the File in Bytes.
$_FILES['upload']['tmp_name'] ==> Returns the Temporary Name of the File.
$_FILES['upload']['name'] ==> Returns the Actual Name of the File.
$_FILES['upload']['type'] ==> Returns the Type of the File.

So if I filetoupload the file 'test.doc', the $_FILES['upload']['name']
would be 'phptut.doc' and $_FILES['upload']['type'] would be
'application/msword'.
---------------------------------------------------------------------*/

Flat File Database
I'm making a flat file database script right now and I need to know if there's a certain limit of characters that can be reached so that the information is written onto the next line.

For example if I had this text file:

hello hello hello hello hello hello hello hello hello hello

If I kept writing "hello", is there a certain limit where hello will go to the next line? Because I'm storing each set of information on it's own line, I don't want one of them to become too long and go onto the next line and mess up the database.

Flat File Database
I am making a simple content management system that allows the users to change the basic text on the page and insert new Articles. This will mean having a simple database with a table for page content and a table for Articles. This will be a flat file system.

I was woundering if this is a bad design and should i create a database with normalised? I will be using php and mysql to grab the information from the database to display it on my web page.

Flat File Database System?
I am researching flat file DBs. I know that they are bad, but a client i am working for does not have access to mysql hosting!

What i need to do is to have a set of special offers (say about 8 different special offers, each one consisting of 5 fields (title, link, description, image, end date)).

Is there a way (either using a php 'random' script or using a flat file or even the explode/implode funcs) to generate a random page to display 2 random special offers?

Database Or Flat File Based?
I'm writing a news script, where I can write articles and have them outputted on my homepage. What I'm wondering before I start is; does anyone have any advice whether something like this would be better of stored in a database or flat files?

Some articles could be quite long and I just thought they may be better suited stored in a .txt file for instance, but then again it might not make any difference.

Converting Flat File To Database
I have a script that looks in a flat text file for an image and coordinates, then plots them on Google Maps in a DIV tooltip. I want to convert the script to database but need to know how it works in order to do so (mainly when there is 2 or more pictures under the same coordinates it will group them in the same DIV and not loads over lapping each other). Code:

Deleting Not Working - Flat File Database
I have to decrypt the $email variable in order to delete from a flat file database. I am not sure how to do this... It decrypts it and trims it to display on a select field, but I don't know how to make it delete. Code:

PHP Flat File Database - How To Load And Edit Lines?
I am using a text file as a database, each field delimited by ||
I want to be able to print all lines to a page, then by selecting one
(with, say, a radio button) it will load into the form at the bottom of
the page, where I can edit the fields, and save back to the same line in
the text file.

I dont know how to use primary keys or anything with a text file
database,

Image Gallery
Greetings all if this is to much I understand, but I've been going around in circles for several weeks, and I'm just not getting it. Let me explain what I'm going for first before I completely keep on blabbing.

My Goal:

I want to create a image gallery site that people can sign up to and upload some of there things to. Sounds simple to some but not to me. I understand to complete this I have many sections to look at. I've been running around google looking for examples and reading about this function and that but still am not getting it completely. Ok so let me try and explain it this way.

I want to create categories for images to be uploaded to. I don't want the images to be uploaded in a database just the folder/file locations. The file I want to stay on the server in a folder. I want to be able to have people sign up and upload to these folders, but lets say someone just wants to see some users stuff then they can pick that user and it would show their images. I also would like to have it to where you have to register to download any images from the site. I bet most are saying this is a big project, I agree...lol! Here is some of the problems I'm not getting.

1. How to do the categories and upload images to folders and store path in a database.

2. How to allow people to upload to those folders.

3. The downloading part.

4. of course have an administration backend for this as well.

The biggest problem I'm having is trying to understand some of the examples out their, and some tutorials don't even help out. If anyone could me some pointers on how I can do this, or some places I can learn how to do this would be appreciated.

Php Image Gallery
I use the Micro Photo Gallery the script finds all .jpg files and creates thumbnails if there isn't one and links the thumbnail with the jpg file.

I will use this script on a site, and I don't want to upload the same gallery on the other site, I just want the script to read from the folder of my first site the files. The original script only reads from the folder that is in. Code:

Image Gallery
I have set up a new website for my son and want to include a gallery however the gallery I want to have it so that there are a collection of thumbnails and when you hover over a thumbnail a large version of the image appears on the left of the screen.

To explain the thumbnails would appear where the blue box is at the right and the large image would appear where the picture is at present.

Can anyone recommend the best way to do this as I know I can do it in Flash but dont really want to use Flash if I can do it in PHP.

Image Gallery
I want my users to be able to upload images where path will be saved to database with a description so I can have a gallery, then members can rate the images. I would like to know what fields im going to need on my table?

Looking For A Image Gallery Script .
does anyone know of a php image gallery script where it catches the imae automatically and displays it on the site, i mean like as soon as i upload he image thru my ftp to that particulay folder, it should kinda like get the image and display it onto the site automatically and it should also have comments, does anyone know how of a script like that.

Creating A Image Gallery
I'm working on a image gallery and I can't figure out the best way to do it. Is it such a good idea to store all images on a MySql database or locally?

If i'm going to store images on a MySql database, how is this done, can you upload a whole directory?

Right now it's coded to load images locally but then comes the problem how to sort everything up, like show 10 images per page, 5 per row etc.

I would like any sugguestions on this. And one more thing, how do I display more than one image per row? Not sure if that's making any sense but here's the code i'm using:

Looking For Mysql/php Image Gallery
Does anyone have any recomendations for an open-source image display that uses MySQL?

PHP/MySQL Image Gallery
PHP/MySQL image
gallery, it doesn't have to be anything fancy, just something that
automatically reads the images in the folder and displays it.

Image Form Gallery
I want to have a row of 5 images and when I click on one of the images I go to another page and it displays that same image. So on the first page I've got this:

<form name="imgForm" action="b.php" method="post">
<input type="image" name="selectedImg" src="1.gif">
<input type="image" name="selectedImg" src="2.gif">
<input type="image" name="selectedImg" src="3.gif">
<input type="image" name="selectedImg" src="4.gif">
<input type="image" name="selectedImg" src="5.gif">
</form>

and on the php page I've got this:

<?php
$selectedImg = $_POST["selectedImg"];
print ("$selectedImg")?>

but when I click nothing shows up. Any ideas?

Image Gallery And Upload
can you give me a tutorial about having an image gallery were you can upload images and if it is not to much trouble can you allso make it so the images are thumb nails and when you click them they pop-up as there actual size?

Recommend Me A Image Gallery Script
I need image gallery script with as much as possible features
like posibillity to make comments, integration with phpbb, detailed stats about the views, different categories and so on.

Image Gallery In Safe Mode
Has any of you fine people found a PHP image gallery that works in Safe
Mode?

I am fed up with downloading one after another when they all seem to fall
down in Safe Mode!!! :-(

I could just write one myself, but it seems a bit excessive when there must
be one out there,

Directory Based Image Gallery
i am try to create a simple script that will read a directory, get the images in it and write them to the page. It would also seperate them in to multiple pages. This is what i have so far Code:

Next Prev Links In The Image Gallery !!
im having a big problem to set up next prev links proparly. Im doing standard image gallery, once in selected category, browser is printing out all thumbs and links to their bigger version. (by id of record) -  i manage to display a big version. but i dont know how to do links to next and prev id in selected category. Code:

Php-based Image Gallery Without Determined Appearance
Does anybody know a php-based image gallery, where final looks of the actual
site would not be determined by the application? I mean that there would
only be a php-library of objects/functions that could be used to incorporate
folders and images to any kind of website with personal appearance.

(Of course administration application should be ready made. I'm not talking
about "send your favorite pics"-community, but image gallery as a part of
centrally administrated corporate website.)

Here's the example what it could be when actually used AS PART OF MY OWN
DESIGN.

<?
if($gallery->hasCurrentCategory() &&
$gallery->currentCategory->hasImages() )
{
while $image = $gallery->currentCategory->fetchImage()
{
...
echo $image->thumbLink("200","200");
....
echo $image->description();
}
}
?>

Simple Image Gallery Needed --Newbie
I was looking at image galleries on the web, but not sure which one to
use... or if to use any of those for what I need.

My requirements are:

1. Fit into design of my site (don't hog the entire page and maintain
color that's already there.
2. Auto-generate thumbnails.
3. Simple interface/presentation
4. SQL database not a problem
5. User uploadable with ID/password, but images viewable by all.
6. Free

I don't need (or really want) something where people can "vote" or
write comments about the pictures. Very simple, elegant, non-intrusive
PHP.

Multiple Page Gallery Without Database
I have 20 images and 20 thumbs. same filenames but in different folders. I have 20 thumbs per page, but if i want to have more, there has to be a link to 2nd page, which shows thumbs from 021.jpg till xxx.jpg. If possible also third and fourth pages. I dont want to use a database. The questions is how to achieve this?

Image File In MySQL Database
I want to be able to save an image file in MySQL database. I realized there are a number of threads on this particular issue. However, the way I am planning to implement it is to have the image save in the MySQL database instead of a link (Blob?)

Upload Image And Save It As Flat Files
how to upload image and save it to a directory and then edit or delete it like making database in flat files .

Dynamic Photo Gallery Based On Mysql Database
I would like to turn my attention to using PHP to organize hundreds of images on my site. I would appreciate some direction. I have in mind putting the image names in a database and will use those names to create links, likely output as a table or drop down menus in a form.

I specifically wonder if there is any way to "dynamically" create thumbnails in PHP from the full image? Alternately, are there any programs out there for "batch creation" of thumbnails?

Help? How To Create Next Buttons When Using A Flat Text Database
Ok, I know the code below does not work but I am wondering about the logic...

1 How do I just print 10 rows.
2 How do I get the buttons.

You get the Idea. Anyway, I would like to know if anyone has done this with text files. I always see mysql as examples but nothing using a flat text database.

<?
$maxResults = 10;
$datafile = "sometextfile.txt";

$rows = @file($datafile);
for($size=0;$size<count($rows);$size++) {
$rows[$size] = chop($rows[$size]);
$coll = split("|",$rows[$size]);


// print something

}
if ($size > 0) {
$currPage = $size / $maxResults;
if ($currPage > 1)
print("<A HREF="test.php" >['prev']</A>");
for ($i = 0; $i < $size / $maxResults; $i++) {
if ($currPage == $i + 1)
printf("<A HREF="test.php"> </A> ",$i + 1);
else
printf("<A HREF="test.php"> </A> ",$i + 1);
}
if ($currPage < size / $maxResults)
print("<A HREF="test.php">['next']</A>);
}
?>

How To Limit Output Lines Per Page Using A Flat Txt Database
I searched the boards for some direction in limiting the output to so many lines like "Back 1 2 3 Next". However, everything is pointing to mysql databases. Has any one did it with a flat text file? This is a sample of how I print to the screen How can I modify this? PHP Code:

Exporting DB Results (or Flat File) To An Excel File
I have two scripts, neither of which have been written, that will need to collect user information. They will either write to a flat file or to a MySQL DB, and I need a way for an administrator to grab an Excel file based on this data.

First, no more than 100 people are expected to sign up, so flat file is certainly viable. Do you recommend I use DB or flat file?

Second, based on your recommendation, how should I go about exporting the user data to an Excel file? There will be about ten form fields per registration to give you an idea.

Flat File
I run a website for a small (very small) AM radio station. I need to add a page where listener's (all seven of them) can list items for sale. (This will be the online version of a daily call-in "For Sale" show that the station runs.) The station owner wants the listings to disappear automatically after 3 days.

My current plan is to let the visitor enter info on a form: telephone no. and item description. The form will tack on a timestamp and then append the data to the target file.

When displaying the data, I need to:

1. Only display data less than 3 days old and...

2. Delete from the file data more than 3 days old.

I'm thinking of having the display page read the file into an array and compare timestamps to a standard. Those that pass are copied into a temporary file. When the entire array has been checked, the temp file is written over the original target file. The temp file is discarded and the new, most current version of the target file is displayed on screen.

Does this seem like a reasonably logical way to do this? I looked at the PHP manual and didn't see a command that removes single entries from a flat file, so this is the approach I came up with. But perhaps I missed something?

I'm using a flat file because I don't anticipate ever having more than just a handful of entries at a time. (I also just want the practice with flat files; I haven't used them as much as I have relational databases.)

A couple of other notes:

Users will not have to have a password or anything like that. They'll just post and the item will stay on the board for three days, as per the station owner's wishes.

The system is being kept simple in part because the owner believes that most of the listeners are elderly and (in his estimation) not super computer types.

Flat File
I know this is a total noob question but im just getting into flat file scripts because a friend of mine has a site that does not have a database. so i told him ill try making him a news script made with flatfile so he doesn't have to switch hosts.. but my question is..

is there a way to delete data thats in flatfile? like set them in an array or something?

Counting In A Flat File
Has anybody an idea, how I can count especially
some records (e.g. different category) in a flat file?

My script only counts the complete lines of the file

...
$count = 15;
$content = file($conf[myDataFile]);
$size = count($content);
...

I want to count each recorset that has the same
value (e.g. category) like the querystring ($cat)
Therefore I have to define the number of the field in the flat file.

...
($myLINES[$i][13]==$cat);
...

Flat File Web Stats In PHP
I'm looking for a basic web stats script that will allow me to count
hits, time and where user goes, as well as browser and OS if possible..
I want to be able to customize it into my template... anybody know of
something prewritten that i can customize?

New Line On The Flat File
i recently decided to code an extreamly simple php cms which i can use on any websites i make. so far i have made an input form, a procesing page, a flat file, and an index with an explode function which shows the last 5 posts newest to oldest.

all of it works up to a point. the problem i have come accross is that when you fill in the message part of the form if you press enter to give a new paragraph it creates a new line on the flat file which the script then thinks is a new line of arrays which makes each new paragraph a new post adding it above its proper post.

i wonder if its possible to somehow stop the line break in the textarea counting as one in the flatfile.. or even better if i can replace it with a < br> tag so it shows as a new paragraph.

New Line In A Flat File?!?!
Made a simple script that can add, edit, or delete objects in a flat file. To use for news, simple ecom, etc. Created the script and tested in on one server and worked perfect. Just moved it to the actual server it will stay on and for some reason what used to make a new line for a new object just adds an upright looking rectangle looking symbol.

Sorry can't copy it here cause it won't show up; will only show up in notepad. Once the symbol is added it will add the new data in the same line is the last object in the flat file. Anyone have any thoughts?!?!?! Code:

Counting Lines In A Flat File
I know that you can count the number of lines with PHP Code:

Flat File Code Generator
I want to know how I can add breaks between table elements (html code) when it's generated from a flat file (input forms) ? Right now the code appears in one continous string, and I'd like it to be neat and tidy (breaking in the code after </td></tr> and </table>) Is this possible? Here's teh code, to show you what I mean :

http://stage.jpauldesign.com/mctl/h.../viewevents.php

PHP Flat File Vs DB For A Small Website
I'm having trouble deciding on whether to go with a flat file or DB
driven architecture for a wee personal website. I'd like to be able to
update HTML files online and this is my only requirement.

Flat Files:
advantage: attach some PHP code at the top of each file that allows the
file to be opened and edited
disadvantage: the files would have to be writeable

DB:
advantage: more secure
disadvantage: allot of overhead

Would anyone have any advice?

PS: I was originally planning to use a CMS but found that no CMS was
customizable enough with little effort for a basic small website -
strang eh :)

Delete Flat File Content
Just have a basic notes.txt to which notes are obviously added to. However, i would like a page "delete.php" to have all content within that file deleted, but keep the notes.txt file intact.

DB -> Flat File, Did I Waste My Time?
In my site I have a config table, (MySQL), with about 30 entries; the
data is loaded on every single page load. This is not the only call to
the db, (we do a total of about 8 calls to the db).
As with many configurations settings, once the options are set the
values will not change much.

So I thought it would be a good idea to move the data to a flat file.
I have written a small wrapper class to first look for the file, if it
exists then load the data from that file, if not the data is loaded
from the database and then saved to a file.
That way I can copy the database without worries about the cached data
itself.

It all works as expected, but the question is, did I waste my time?
How can I do some load test on my server to see what would be better?
Database call or flat file read.

Replacing A Record In A Flat File
I am trying to replace a single record in a flat file. The file is
relatively small and no need for database.

I open the file, and save the ftell() value in a variable.
I read a record using fgetcsv(), modify the index contents it if/as
necessary.
I then position the pointer back to the beginning of that record using
fseek(value_from_ftell).
I build a new string with the required delimiters.
Finally I put the record with fputs() (also fails with fwrite()).

What the code actually does, is append a NEW record to the end. Can't seem
to find out hot to REPLACE the original record with the new data.

Code:
---------
$fp = fopen('filename');
$filerec = ftell($fp);
-->for...next
$user = fgetcsv($fp, 999, " ");
/*
Code here to change as required $user[0-6]
*/
$outputstr = $user[0]." ".$user[1]." ". etc, etc
fseek($filerec);
fputs($fp, $outputstr);
-->next
fclose($fp);

Deleting Lines From Flat File
I am trying to display all the news items in my flat file with 'delete' links (<a href="managedeletenews.php?action=delete&id=$key">Delete[/url]) that call the same page to strip out the line and rewrite the file.

However, when the delete link is clicked nothing happens (except the page's address changing from "managedeletenews.php" to the above.

Am I using the references to the $id or $key variables incorrectly?
Is it something to do with the undefined $action variable?
Or is it something else??
BTW, the embedded styles for the delete link - shown below - don't seem to be throwing up any errors. Code:

Using A Flat File For Large Queries.
I have 13 rows of information, and instead of storing that little amount of data in the database, I figured I should save some storage and put the information in a flat file instead. Lets say my flat file looks like this:

Account type (int) | amount (int)| more info
Account type (int) | amount (int)| more info
Account type (int) | amount (int)| more info

Lets say my database table looks like this and there are about 5,000 rows.

UserID
Account_type

Would it be insane to loop through the flat file for each individual DB entry and find the matching "account type" for that individual user, then add the "amount" field to a row in the DB according to what account type they have? Or would this be a lot easier if I just stored the flat file information in a table in the database?

Displaying Data From A Flat File?
ive got a flatfile database sorted out, all i need now is how to store individual flat files per user and how to paginate that data. Just to make sure i'm doing everything right, i'll post the code below Code:

Flat File And Passing Data
I am currently working on a project whereby users login to my website (which is working) and then using a form add new links/tabs to their navigation bar (which i need help developing). So for instance if the user had 'home/search engines/favourites' as links on their navigation bar and they wanted to add auction sites as a group title they fill out the form which wants the name of the link and the URL it goes to.

So far i can make the form send the link name and URL to my flat file database (usertabs.txt) but i also need the form to once submitted automatically insert the users username before the link and URL to make their new link unique to them. So in the flat file the structure will be:

username|Link name|URL

The usernames etc are stored in a separate .txt file.
I have this code so far which is the basis for uploading new links to a users navigation bar. $userid is the variable i want to be associated with the user who is logged on. Code:

Flat File Display <i>x</i> Number Of Lines
I have a "site updates" script that I wrote that stores my site updates in a flat file in the form:

21234123|>|blah blah blah
21234123|>|blah blah blah
21234123|>|blah blah blah

where 21234123 is a unix timestamp.

what I want, is to be able to display the last x updates on my main page. I have a "updates.php" page which displays ALL updates... but I want to display just the say... most recent 3 or 5 updates at the bottom of my main page.

This is my function that displays -all- updates.

PHP Flat File Search Engine (a La Lucene)
Wonder if someone could help me. I'm looking for a PHP/MySQL based
search engine that can search flat files i.e. build it's own index
from flat files. I've used Apaches' Lucene before
(http://jakarta.apache.org/lucene/docs/index.html), so I'm looking for
something similar. If there's a pay-for product out there, I don'd
mind paying.

So, it needs:
- Ability to search a set of flat files and build an index
- Allow users to enter BOOLEAN operators, e.g. dog AND cat OR donkey
- Return results on an accuracy match basis e.g. no. of times all
words in search phrase occured in a file/record


Copyright © 2005-08 www.BigResource.com, All rights reserved