Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need a little php help
#1
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.
Reply
#2
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 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;[email protected]
# Created 18.04.2003
# Dacio's PHP scripts &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;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 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [email protected]
# Modified August 13, 2004 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 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"; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //filename photo list
$nr = "potd/pnumber.inc"; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //file with counter
$arhiv = "potd/arhiv.txt"; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//arhiv photo list

if (file_exists ($flist)) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//if exist $flist
&nbsp; &nbsp;$photo = file($flist); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //file with photo list
}
if (file_exists ($nr)) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //if exist $nr
$date_mod = date("d.m.y", filemtime ($nr)); //check files modified date
}
$date = date("d.m.y"); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //todays date



//directory where photos are stored;don't forget "/" at the end
$inc_ext = ".inc"; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Puts the .inc at the end of the quote file name
$quote_folder = "potd/potd_quote/"; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //Image Quote
$photo_thumbdir = "potd/potd_thumbs"; &nbsp; &nbsp; &nbsp; &nbsp;//Thumbnails folder
$photo_dir = "potd/potd"; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//Photos folder
$photo_width = "90%"; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//photo width
$photo_border = "0"; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //photo border
$photo_alt = "VadaVaka's PotD"; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//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) &nbsp; &nbsp; #
# AND makes new one with photo list &nbsp; &nbsp; &nbsp; #
###########################################
if (file_exists ($flist)) {
&nbsp;unlink ($flist);
}
$handle = opendir($photo_dir);
while (false !== ($file = readdir($handle))) {
&nbsp; &nbsp; &nbsp; if ($file != "." &amp;&amp; $file != "..") {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$aq = fopen ($flist,"a+");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fputs ($aq, $file."\n");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fclose ($aq);
&nbsp; &nbsp; &nbsp; }
}
closedir($handle);
////////////////////////////////////////////////////////////////////

###########################################
# check date_mod not same as todays date &nbsp;#
# AND run script &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#
###########################################
if ($date_mod != $date) {

&nbsp;###############################################################
&nbsp;# if file exist read the number and encrease it by one &nbsp; &nbsp; &nbsp; &nbsp;#
&nbsp;# then show photo where line is same as number in pnumber.inc #
&nbsp;###############################################################
&nbsp;if (file_exists ($nr)) {
&nbsp; &nbsp; &nbsp; &nbsp;$fp = fopen ($nr,"r+");
&nbsp; &nbsp; &nbsp; &nbsp;$qc = fgets ($fp,4);
&nbsp; &nbsp; &nbsp; &nbsp;$qc = chop ($qc);
&nbsp; &nbsp; &nbsp; &nbsp;$qc += 1;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if ($qc >= count($flist))
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$qc == 0;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rewind ($fp);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fputs ($fp,substr($qc." &nbsp; ",0,4));
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fclose ($fp);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;echo "<center><font COLOR=\"GOLDENROD\" face=\"verdana\" size=\"-1\"><h4>$photo_alt</h4></font>";
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;echo "<A HREF=\"$photo_dir/$photo[$qc]\" TARGET=_NEW $photo_info><img src=\"$photo_thumbdir/$photo[$qc]\" $photo_info></A>";
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$quote_potd = $quote_folder.$photo[$qc].$inc_ext;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;echo $quote_potd;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;include ("$quote_potd");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# include ("copyright.inc");

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//write info when did photo displayed AND which one
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;$ap = fopen ($arhiv,"a");
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fputs ($ap, $date."\t".$photo[$qc]);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;fclose ($ap);


&nbsp;###############################################################
&nbsp;# if file don't exist, make it and add null &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #
&nbsp;# then show photo where line is same as number in pnumber.inc #
&nbsp;###############################################################
&nbsp;} else {
&nbsp; &nbsp; &nbsp; &nbsp;$fp = fopen($nr,"w");
&nbsp; &nbsp; &nbsp; &nbsp;$qc = 0;
&nbsp; &nbsp; &nbsp; &nbsp;fputs ($fp,substr($qc." &nbsp; ",0,4));
&nbsp; &nbsp; &nbsp; &nbsp;fclose ($fp);
&nbsp; &nbsp; &nbsp; &nbsp;echo "<center><font COLOR=\"GOLDENROD\" face=\"verdana\" size=\"-1\"><h4>$photo_alt</h4></font>";
&nbsp; &nbsp; &nbsp; &nbsp;echo "<A HREF=\"$photo_dir/$photo[$qc]\" TARGET=_NEW $photo_info><img src=\"$photo_thumbdir/$photo[$qc]\" $photo_info></A>";
&nbsp; &nbsp; &nbsp; &nbsp;$quote_potd = $quote_folder.$photo[$qc].$inc_ext;
&nbsp; &nbsp; &nbsp; &nbsp;echo $quote_potd;
&nbsp; &nbsp; &nbsp; &nbsp;include ("$quote_potd");

&nbsp;}

##########################################################
# 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);

}
?>
Reply
#3
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. :)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)