I am trying to run a simple script for a photography site I'm working on. I'm not great with PHP, so if the error is obvious, please don't flame me. [img]images/smilies/blush.gif[/img]
PHP Code:
<?php
// file locations
$imagefile = "imagelist.txt"; // location of the list of images
$titlefile = "titlelist.txt"; // location of the list of titles
// OPEN THE FILES, GET AN ARRAY, THEN CLOSE AND IGNORE THEM
// assign some variables
$delim = "\n";
// Open and explode Images List file
$tp = fopen($imagefile, "r" );
$contents = fread($tp, filesize($imagefile));
$image_arr = explode($delim,$contents);
fclose($tp);
// Open and explode Title List file
$fp = fopen($titlefile, "r" );
$contents = fread($fp, filesize($titlefile));
$title_arr = explode($delim,$contents);
fclose($fp);
// check to see the sizes of the arrays
$image_arr_size = count($image_arr);
$title_arr_size = count($title_arr);
// DISPLAY THE IMAGE
// NOTE: The 1st item in an array is zero, so decreasing $i and putting in $mnum will give us the correct string
// I.E.: 0, 1, 2, 3 ... "2" is the THIRD string
$mnum = $i - 1;
// get the image and title
$image = $image_arr[$mnum];
$title = $title_arr[$mnum];
// Strip whitespace from the beginning and end of string
$image = trim($image);
$title = trim($title);
// PRINT THE STUFF
if ($image_arr_size != $title_arr_size) {
// If the two files are not the same size, edit them!
print("The image and title files are not the same size, please fix this problem." );
}else{
// All is good. Continue.
$end = $title_arr_size;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
...
...
And then, down a little further
Code:
<td class="photo"><img src="<? print('$image'); ?>" alt="Photo by Adam Polselli" width="500" height="376" border="0"></td>
</tr>
<tr>
<td class="small" colspan="2"><? print('$title'); ?></td>
</tr>
</table>
I'm getting this error:
"Parse error: parse error, unexpected $ in /home/adamp/public_html/photography/test.php on line 105"
BTW, line 105 is only: </html>
Thanks in advance! [img]images/smilies/smile.gif[/img]
Bookmarks