SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    Former Staff Member silver trophy Adam P.'s Avatar
    Join Date
    Apr 2001
    Location
    San Francisco
    Posts
    3,288
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy 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($tpfilesize($imagefile)); 
    $image_arr explode($delim,$contents); 
    fclose($tp);
    // Open and explode Title List file
    $fp fopen($titlefile"r" );
    $contents fread($fpfilesize($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]
    SPF Mentor/Advisor 2001-2003
    SPF Designer of the Year 2002
    SPF Graphic Designer of the Year 2003
    AdamPolselli.com

  2. #2
    + platinum's Avatar
    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;"

  3. #3
    Former Staff Member silver trophy Adam P.'s Avatar
    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

  4. #4
    + platinum's Avatar
    Join Date
    Jun 2001
    Location
    Adelaide, Australia
    Posts
    6,441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hehe glad it's all working

  5. #5
    Former Staff Member silver trophy Adam P.'s Avatar
    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

  6. #6
    + platinum's Avatar
    Join Date
    Jun 2001
    Location
    Adelaide, Australia
    Posts
    6,441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if ($i != $end || $i == ""
    should do it

  7. #7
    Former Staff Member silver trophy Adam P.'s Avatar
    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

  8. #8
    + platinum's Avatar
    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)) 

  9. #9
    Former Staff Member silver trophy Adam P.'s Avatar
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •