Need a little php help - Gwarsbane - 08-13-2004
Ok basically what the script does is gets a files name and then show it as a picture. That part works. What I'm trying to do is run a inc file that has the same name as the jpg but also has the .inc added onto the end of it so that I can put a caption under the picture that matches the image without having to put it in manually.
The slight problem I am having is that it gets the name of the jpg and adds it to the .inc but for some reason it puts a space inbetween the name and the .inc.
Here is the code, I will post the full code in the another message...
Code: $inc_ext = ".inc"; //Puts the .inc at the end of the quote file name
$quote_folder = "potd/potd_quote/"; //Image Quote
The above code was used to setup the folder
The code below is one of the pieces of code I have tried. When I used the echo line I would get potd/potd_quote/post-5-1088106344.jpg .inc
$quote_potd = $quote_folder.$photo[$qc]."$inc_ext";
# echo $quote_potd;
include ("$quote_potd");
I get the error messages...
Warning: main(potd/potd_quote/post-5-1088106344.jpg .inc): failed to open stream: No such file or directory in /srv/www/vadavaka/test.php on line 203
Warning: main(): Failed opening 'potd/potd_quote/post-5-1088106344.jpg .inc' for inclusion (include_path='.:/usr/share/php') in /srv/www/vadavaka/test.php on line 203
heck I even created the files with the space in it and I still get those error message. The line that the error is on is off because have lots of other code above this.
Need a little php help - Gwarsbane - 08-13-2004
Heres the full code...
***Edit***
The code is fully working now like I wanted it too:)
Code: <?
################################################################################
# Dacio's Picture of the day v1.0
# Copyright 2003 by Dacio [email protected]
# Created 18.04.2003
# Dacio's PHP scripts http://www.geocities.com/daciofit/script
#
# This script is free to use and modify. However it is not free to
# re-distribute without written permission from the author.
#
# Change below to suit your needs
#
#
# Mods done by Nick Julian in 2004 [email protected]
# Modified August 13, 2004 http://gwars.mektek.net
# Mods added in: 1) Open picture of the day in a new window
# 2) Use small thumbnail instead of the full image for the potd to make page
# load up quicker so that larger/higher quality images can be used.
#
# Save thumbs with the exact same name as the original image (including the
# extention) into the thumbs folder and save them with photoshop 7 or 8 at a
# quality of 3 and a width of 200 px
################################################################################
# See readme.txt for more info
################################################################################
$flist = "potdst.txt"; //filename photo list
$nr = "potd/pnumber.inc"; //file with counter
$arhiv = "potd/arhiv.txt"; //arhiv photo list
if (file_exists ($flist)) { //if exist $flist
$photo = file($flist); //file with photo list
}
if (file_exists ($nr)) { //if exist $nr
$date_mod = date("d.m.y", filemtime ($nr)); //check files modified date
}
$date = date("d.m.y"); //todays date
//directory where photos are stored;don't forget "/" at the end
$inc_ext = ".inc"; //Puts the .inc at the end of the quote file name
$quote_folder = "potd/potd_quote/"; //Image Quote
$photo_thumbdir = "potd/potd_thumbs"; //Thumbnails folder
$photo_dir = "potd/potd"; //Photos folder
$photo_width = "90%"; //photo width
$photo_border = "0"; //photo border
$photo_alt = "VadaVaka's PotD"; //photo alt text
//don't change below ////////////////////////////////////////////////
$w = "width=".$photo_width;
$b = "border=".$photo_border;
$a = "alt=\"".$photo_alt."\"";
$photo_info = $w." ".$b." ".$a;
###########################################
# here deletes $photo file (if exist) #
# AND makes new one with photo list #
###########################################
if (file_exists ($flist)) {
unlink ($flist);
}
$handle = opendir($photo_dir);
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$aq = fopen ($flist,"a+");
fputs ($aq, $file."\n");
fclose ($aq);
}
}
closedir($handle);
////////////////////////////////////////////////////////////////////
###########################################
# check date_mod not same as todays date #
# AND run script #
###########################################
if ($date_mod != $date) {
###############################################################
# if file exist read the number and encrease it by one #
# then show photo where line is same as number in pnumber.inc #
###############################################################
if (file_exists ($nr)) {
$fp = fopen ($nr,"r+");
$qc = fgets ($fp,4);
$qc = chop ($qc);
$qc += 1;
if ($qc >= count($flist))
$qc == 0;
rewind ($fp);
fputs ($fp,substr($qc." ",0,4));
fclose ($fp);
echo "<center><font COLOR=\"GOLDENROD\" face=\"verdana\" size=\"-1\"><h4>$photo_alt</h4></font>";
echo "<A HREF=\"$photo_dir/$photo[$qc]\" TARGET=_NEW $photo_info><img src=\"$photo_thumbdir/$photo[$qc]\" $photo_info></A>";
$quote_potd = $quote_folder.$photo[$qc].$inc_ext;
echo $quote_potd;
include ("$quote_potd");
# include ("copyright.inc");
//write info when did photo displayed AND which one
$ap = fopen ($arhiv,"a");
fputs ($ap, $date."\t".$photo[$qc]);
fclose ($ap);
###############################################################
# if file don't exist, make it and add null #
# then show photo where line is same as number in pnumber.inc #
###############################################################
} else {
$fp = fopen($nr,"w");
$qc = 0;
fputs ($fp,substr($qc." ",0,4));
fclose ($fp);
echo "<center><font COLOR=\"GOLDENROD\" face=\"verdana\" size=\"-1\"><h4>$photo_alt</h4></font>";
echo "<A HREF=\"$photo_dir/$photo[$qc]\" TARGET=_NEW $photo_info><img src=\"$photo_thumbdir/$photo[$qc]\" $photo_info></A>";
$quote_potd = $quote_folder.$photo[$qc].$inc_ext;
echo $quote_potd;
include ("$quote_potd");
}
##########################################################
# show photo where line is same as number in pnumber.inc #
##########################################################
} else {
$fp = fopen ($nr,"r");
$qc = fgets ($fp,4);
$qc = chop ($qc);
fclose ($fp);
echo "<center><font COLOR=\"GOLDENROD\" face=\"verdana\" size=\"-1\"><h4>$photo_alt</h4></font>";
echo "<A HREF=\"$photo_dir/$photo[$qc]\" TARGET=_NEW $photo_info><img src=\"$photo_thumbdir/$photo[$qc]\" $photo_info></A>";
$test = $photo[$qc];
$test = substr($test, 0, strlen($test)-1);
$quote_potd = $quote_folder.$test.$inc_ext;
# echo $test;
# echo $quote_potd;
include ($quote_potd);
}
?>
Need a little php help - Gwarsbane - 08-13-2004
Never mind got it all working now.
Thanks to Miagi for pointing me in the right direction and being there for me to bounce ideas off of. :)
|