Grow your CSS skills. Land your dream job.

[Solved] Parse Error installing #64 Building a Photo Gallery

  • # August 23, 2009 at 12:14 pm

    I’m tiring to install the photo gallery that is featured on this site (#64 Building a Photo Gallery). I have all my folders and directories setup, my imgbrowz0r.php is in the inc folder, but when I try to view the page I get this message.


    Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /home/shepa0/public_html/chris/imgbrowz0r/inc/imgbrowz0r.php on line 37

    Fatal error: Cannot instantiate non-existent class: imgbrowz0r in /home/shepa0/public_html/chris/imgbrowz0r/index.php on line 65



    First off there is nothing on line 37.
    Second this is what is on like 65: $gallery = new imgbrowz0r($config);

    Here is a link to the live page:
    http://shepardsuperteam.com/chris/imgbrowz0r/index.php

    And hers my code. Please let me know If I have anything out of place.


    Code:
    < ?php

    error_reporting(E_ALL);

    // Some stuff for generating stats
    function file_size($size)
    {
    $units = array('b', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Eb');

    for ($i = 0; $size > 1024; $i++)
    $size /= 1024;

    return round($size, 2).’ ‘.$units[$i];
    }

    function get_microtime($microtime=false)
    {
    if ($microtime === false)
    $microtime = microtime();

    list($usec, $sec) = explode(‘ ‘, $microtime);
    return ((float)$usec + (float)$sec);
    }

    $start_timer = microtime();

    // Include class
    require ‘http://shepardsuperteam.com/chris/imgbrowz0r/inc/imgbrowz0r.php';

    // These are all settings (set to default). The settings are not validated since you have to configure everything.
    // There is a chance that ImgBrowz0r stops working if you enter the wrong values.
    $config = array(
    // Directory settings. These are required. Without trailing slash. (required)
    ‘images_dir’ => ‘http://shepardsuperteam.com/chris/imgbrowz0r/gallery’,
    ‘cache_dir’ => ‘http://shepardsuperteam.com/chris/imgbrowz0r/cache’,

    ‘main_url’ => ‘http://shepardsuperteam.com/chris/imgbrowz0r/index.php’,
    ‘images_url’ => ‘http://shepardsuperteam.com/chris/imgbrowz0r/images’,
    ‘cache_url’ => ‘http://shepardsuperteam.com/chris/imgbrowz0r/cache’,

    // Sorting settings (optional)
    ‘sort_by’ => 3, // 1 = filename, 2 = extension (png, gif, etc.), 3 = inode change time of file
    ‘sort_order’ => false, // true = ascending, false = descending

    // Thumbnail settings (optional)
    ‘thumbs_per_page’ => 12, // Amount of thumbnails per page
    ‘max_thumb_row’ => 4, // Amount of thumbnails on a row
    ‘max_thumb_width’ => 200, // Maximum width of thumbnail
    ‘max_thumb_height’ => 200, // Maximum height of thumbnail

    // Time settings (optional)
    ‘time_format’ => ‘F jS, Y’, // Date formatting. Look at the PHP date() for help: http://nl3.php.net/manual/en/function.date.php
    ‘time_zone’ => 0, // Timezone. Example: 1
    ‘enable_dst’ => false, // Daylight saving time (DST). Set this to true to enable it.

    // Misc settings (optional)
    ‘ignore_port’ => false, // Ignore port in url. Set this to true to ignore the port.
    ‘dir_thumbs’ => true, // Show a thumbnail in a category box. Default is false.
    ‘random_thumbs’ => false, // Use random thumbnails for categories. Default is false.
    ‘read_thumb_limit’ => 0 // See README for information about this setting.
    );

    // Start the class
    $gallery = new imgbrowz0r($config);

    // XHTML stuff
    ?>< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">



    < ?php

    // Prepare everything. This function must be called before you call other functions.
    $gallery->init();

    // Generate navigation and statistics
    $gallery_breadcrumbs = $gallery->breadcrumbs();
    $gallery_pagination = $gallery->pagination();
    $gallery_statistics = $gallery->statistics();

    // Display navigation
    echo ‘

    ‘, “nt”, $gallery_breadcrumbs, “nt”, $gallery_pagination, “nt”, $gallery_statistics, “n”, ‘

    ‘, “nn”;

    // Display images and directories
    echo $gallery->browse();

    // Display navigation
    echo ‘

    ‘, “nt”, $gallery_pagination, “nt”, $gallery_breadcrumbs, “n”, ‘

    ‘, “nn”;

    // Showing some stats
    echo ‘

    Processing time: ‘, round(get_microtime(microtime()) – get_microtime($start_timer), 5), ‘ && Memory usage: ‘, file_size(memory_get_usage()), ‘

    ‘;

    ?>


    # August 23, 2009 at 1:19 pm

    Read the error messages.
    The problem is on line 37 (or before) of imgbrowz0r.php, which is why the class can’t be called on line 65 of index.php.

    # August 23, 2009 at 4:14 pm

    Sorry, I’m still not seeing the problem. I forgot to mention this is my first time messing with anything PHP.

    I looked back on the video (#64 Building a Photo Gallery) and noticed that he had a ?q=%PATH% on the back end of his link to the main_url. I remember having that in there before but I deleted it because I thought it was junk added on from Dreamweaver, but I put it back on (that’s) on line 38, so now it reads like this.

    38| ‘main_url’ => ‘http://shepardsuperteam.com/chris/imgbrowz0r/index.php?q=%PATH%’,

    line 65 still reads like this

    65|$gallery = new imgbrowz0r($config);

    Do you see anything wrong between these two codes?

    # August 23, 2009 at 4:45 pm

    I repeat:

    The problem is on line 37 (or before) of imgbrowz0r.php

    # August 23, 2009 at 6:54 pm

    The problem is on line 37 (or before) of imgbrowz0r.php

    Ok. So what do I do with this information. "imgbrowz0r.php" only shows up on line 28. Is it written wrong, directing wrong, wrong file name?

    p.s. Thanks for the help so far.

    # August 24, 2009 at 6:51 am

    imgbrowz0r.php is a file in the "inc" directory.

    # August 24, 2009 at 10:12 am

    Yes, I know what it is and where it’s at. I just don’t understand what it’s saying about the file. It’s in the right directory. It wasn’t mirrored on my hard drive, but I fixed that with no change.

    I just fond this message in my live log on the server.

    [24-Aug-2009 06:59:52] PHP Fatal error: Cannot instantiate non-existent class: imgbrowz0r in /home/shepa0/public_html/chris/imgbrowz0r/index.php on line 65

    # August 24, 2009 at 10:25 am

    Sorry but I don’t know how to make it any clearer. The problem is on (or before) line 37 of imgbrowz0r.php.

    EDIT.
    Are you sure your server is running PHP5 and not PHP4?

    # August 24, 2009 at 12:05 pm

    They use something called suPHP. Ever heard of it?

    # August 24, 2009 at 3:40 pm

    Now I know what imgbrowz0r is I’m guessing that you haven’t altered that file in any way? I can only surmise that suPHP is the problem. Have you tried the gallery locally using Manp or Xampp or whatever?

    # September 4, 2009 at 1:03 pm

    Okay. I believe my problem was the server was using PHP 4.9 and not 5. So as far as this post Its resolved.

    # September 18, 2009 at 2:10 am

    Hello Friends,I have some problem regarding parsing.
    I am getting Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING error, here are the lines:
    for($i=0; $i<12; $i++){
    $aquery = "INSERT INTO uaq_scbatsmen VALUES(‘$row2′, ‘a’, ‘$a_player[$i]’, ‘$a_out[$i]’, ‘$a_balls[$i]’, ‘$a_4s[$i]’, ‘$a_6s[$i]’, ‘$a_runs[$i]’)";
    mysql_query($aquery);
    }
    The problem line is the middle one ($aquery). Most probably problem is that I am missing some " or ; or something else but after hours of head banging I still can’t find the problem.
    Regards
    Jenifer
    Support executive

Viewing 12 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".