SitePoint Sponsor |
|
User Tag List
Results 1 to 9 of 9
-
Apr 27, 2003, 11:58 #1
- Join Date
- Apr 2001
- Location
- San Francisco
- Posts
- 3,288
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Argh! Please help me find the Parse Error
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>
...
...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>
"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]SPF Mentor/Advisor 2001-2003
SPF Designer of the Year 2002
SPF Graphic Designer of the Year 2003
AdamPolselli.com
-
Apr 27, 2003, 12:14 #2
- Join Date
- Jun 2001
- Location
- Adelaide, Australia
- Posts
- 6,441
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I think you're missing a } after "$end = $title_arr_size;"
-
Apr 27, 2003, 12:22 #3
- Join Date
- Apr 2001
- Location
- San Francisco
- Posts
- 3,288
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
(soothing) ah..... the beautiful sound of the "hallelujah" song that goes along with this sort of revelation.
Thanks!
SPF Mentor/Advisor 2001-2003
SPF Designer of the Year 2002
SPF Graphic Designer of the Year 2003
AdamPolselli.com
-
Apr 27, 2003, 12:24 #4
- Join Date
- Jun 2001
- Location
- Adelaide, Australia
- Posts
- 6,441
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
hehe
glad it's all working
-
Apr 27, 2003, 13:02 #5
- Join Date
- Apr 2001
- Location
- San Francisco
- Posts
- 3,288
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
One more thing. I guess I'll just post in here.
Can you make multiple conditions for an if statment? For example, I want it to be...
if ($i != $end) or ($i == "")
Is there any way to do that? Thanks! [img]images/smilies/smile.gif[/img]SPF Mentor/Advisor 2001-2003
SPF Designer of the Year 2002
SPF Graphic Designer of the Year 2003
AdamPolselli.com
-
Apr 27, 2003, 13:13 #6
- Join Date
- Jun 2001
- Location
- Adelaide, Australia
- Posts
- 6,441
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
PHP Code:if ($i != $end || $i == "")
-
Apr 27, 2003, 13:21 #7
- Join Date
- Apr 2001
- Location
- San Francisco
- Posts
- 3,288
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
K, that didn't work, but I think it was my fault. For the second part, I want it to be "or if $i is not set as anything." I think there's a way, but I forgot how.
SPF Mentor/Advisor 2001-2003
SPF Designer of the Year 2002
SPF Graphic Designer of the Year 2003
AdamPolselli.com
-
Apr 27, 2003, 13:26 #8
- Join Date
- Jun 2001
- Location
- Adelaide, Australia
- Posts
- 6,441
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
That should work if $i isn't set?
if $i does not equal $end or if $i equals nothing is what it reads at the moment
maybe this is what you were thinking..
PHP Code:if ($i != $end || !isset($i))
-
Apr 27, 2003, 13:34 #9
- Join Date
- Apr 2001
- Location
- San Francisco
- Posts
- 3,288
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
EDIT: nm
SPF Mentor/Advisor 2001-2003
SPF Designer of the Year 2002
SPF Graphic Designer of the Year 2003
AdamPolselli.com
Bookmarks