Hi

I am really struggling here and cant see the syntax error.

It is probably a " but could really do with a hand as to why I get the error:

unsxpected T_STRING on line 14

My php code is as follows:

<?php
 
include_once("php/library/lib.php");
include_once("php/library/template.php");
include_once("php/library/database.php");
 
 
//
//$database = new database();//$security = new security();//$security->allowed_get("PHPSESSID");//$security->check_vars(false);//
$page = new template( "index.html" );
//$page->lockToLoggedIn = false;
//$security->set_counters(page);//$page->setRegionVisable("lines",true);// Build the actual page contents display
//$pageDtls = '<table cellpadding=0 cellspacing=0 border=0>';//$pageDtls .= '<tr><td>';//$pageDtls .= '<?region-start id="lines" type="repeat" ?>';//$pageDtls .= '<center>';//$pageDtls .= '<table class="browseContents" width="100%" border="0" cellspacing="0" cellpadding="1">';//$pageDtls .= '<tr>';
//$pageDtls = '<table cellpadding=0 cellspacing=0 border=0><tr><td><?region-start id="lines" type="repeat" ?><center><table class="browseContents" width="100%" border="0" cellspacing="0" cellpadding="1"><tr>';
//
//$img_width = 85;//$img_height = 30;
// Build a grid of ALL cells
//for ( $cat_set = 1 ; $cat_set < (MAX_CATS + 1); $cat_set ++ )//{// $categories = array();// $cat_hdrs = array();//
//// // Find all Categories for the current set//// $sqlQry = "SELECT *// FROM categories// WHERE cat_set_no = " . $cat_set . "// ORDER BY cat_pos_no";//
// $result = $database->runQuery( $sqlQry );// $rows = $database->numRows();//
// for ($a = 0 ; $a < $rows ; $a ++ )// {// $catObj = $database->getObject();//// $categories[$catObj->cat_pos_no -1] = $catObj->cat_id;// $cat_hdrs[$catObj->cat_pos_no -1] = $catObj->cat_name;// }////
// // Set the category headers//// for ( $cat_no = 0 ; $cat_no < 10; $cat_no ++ )// {// $pageDtls .= '<td id="hdrCell" valign="top">' . $cat_hdrs[$cat_no] . '</td>';// $pageDtls .= '<td id="spaceCell">&nbsp;</td>';// }////// $pageDtls .= '</tr>';// $pageDtls .= '<?repeat-line-start?>';//
// // Set Cell Details//
// for ( $line_no = 1 ; $line_no < (MAX_ROWS + 1); $line_no ++ )// {// $pageDtls .= '<tr>';//
// for ( $cat_no = 0 ; $cat_no < 10; $cat_no ++ )// {// $pageDtls .= '<td id="singleCell" valign="top">';//// $cellObj = $database->getSingleObject("SELECT *// FROM cells// WHERE cell_category = '" . $categories[$cat_no] . "'// AND cell_no = " . $line_no);//// if ($cellObj != null)// {// if ($cellObj->cell_status === "R")// {// $pageDtls .= '<a href="#">';// $pageDtls .= '<img src="/pages/images/img_reserved.png" width=' . $img_width . ' height=' . $img_height . ' border="1">';// }//
// if ($cellObj->cell_status === "S")// {// $pageDtls .= '<a href="' . $cellObj->cell_url . '">';// $pageDtls .= '<img src="/pages/sold/' . $cellObj->cell_image . '" width=' . $img_width . ' height=' . $img_height . ' border="1">';// }// }// else// {// $pageDtls .= '<a href="' . STORE_PATH . 'buy.php?category='. $categories[$cat_no] . '&cell=' . $line_no . '">';// $pageDtls .= '<img src="/pages/images/img_available.png" width=' . $img_width . ' height=' . $img_height . ' border="1">';// }//// $pageDtls .= '</a>';// $pageDtls .= '</td>';// $pageDtls .= '<td id="spaceCell">&nbsp;</td>';// }//// $pageDtls .= '</tr>';// }//}//
//unset($database);//
//$pageDtls .= '<?repeat-line-end?>';//$pageDtls .= '</table>';//$pageDtls .= '</center>';//$pageDtls .= '<?region-end?>';//$pageDtls .= '</td></tr>';//$pageDtls .= '</table>';//$page->setItem( "page-details" , $pageDtls );
 
// Display the page
 
echo $page->process();
 
?>

I am desperate for some help as I have been staring at this for a day or so.

all the best

Pete

First off please put your code inside of the php code tags

[php] Code here [/php]

The error is on line 14 but I can't really tell where line 14 starts in your code. Please either clean the code up a little or just give use lines 12-17 or something like that. Thanks

//$security->set_counters(page);//$page->setRegionVisable("lines",true);// Build the actual page contents display
//$pageDtls  = '<table cellpadding=0 cellspacing=0 border=0>';//$pageDtls .= '<tr><td>';//$pageDtls .= '<?region-start id="lines"  type="repeat" ?>';//$pageDtls .= '<center>';//$pageDtls .= '<table class="browseContents" width="100%" border="0" cellspacing="0" cellpadding="1">';//$pageDtls .= '<tr>';
//$pageDtls  = '<table cellpadding=0 cellspacing=0 border=0><tr><td><?region-start id="lines"  type="repeat" ?><center><table class="browseContents" width="100%" border="0" cellspacing="0" cellpadding="1"><tr>';
//
//$img_width  = 85;//$img_height = 30;
// Build a grid of ALL cells

lines 12 - 17 as requested thanks for your help
Pete

Well the error isn't in those lines because they are all commented out. The only thing I could see is that maybe the error is in one of the included files.

I can tell you that my personal experiences not T_STRING, as in your case, but T_INC came from not putting the "$" sign in front of a variable in a for loop. Check your syntax on your strings and your problem may be hidden somewhere in one of them...

It took me a lot of searching on the internet one day for something so simple. Then, after a some sleep, i woke up and saw the obvious mistake, corrected it, and the program worked perfectly.

do you notice the de color of the code chanched after

<?region-start id="lines" type="repeat" ?>

the ?> tag closes the php sesion despate it being commened out by //

use of /* */ comment will solve this

I just got Deja vu reading this thread. Twice I thought "I wrote that" and saw someone elses name. Am I having that much of an effect here? :-)

I had this problem in Joomla! with my php code that I was including in an article through the plugin sourcerer. Well, needless to say, my web hosting changed to php 4 without me knowing why, I changed it to php 5 as the compiling engine and it worked like a charm.

I had this problem in Joomla! with my php code that I was including in an article through the plugin sourcerer. Well, needless to say, my web hosting changed to php 4 without me knowing why, I changed it to php 5 as the compiling engine and it worked like a charm.

I'm pretty sure you just bumped a thread that was over 2 years old, that has to fit into the Daniweb drinking game if it exists.

Drink up buddy!!! funny

I desperately need and answer the error code:
i got this error when i try to log in using administrator on our joomla website . your help is much appreciated.

<?php
/**
* @version $Id: index.php 8078 2007-07-19 06:45:54Z robs $
* @package Joomla
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license [url]http://www.gnu.org/copyleft/gpl.html[/url] GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// Set flag that this is a parent file
define( '_VALID_MOS', 1 );

if (!file_exists( '../configuration.php' )) {
    header( 'Location: ../installation/index.php' );
    exit();
}

require( '../globals.php' );
require_once( '../configuration.php' );

// SSL check - $http_host returns <live site url>:<port number if it is 443>
$http_host = explode(':', $_SERVER['HTTP_HOST'] );
if( (!empty( $_SERVER['HTTPS'] ) && strtolower( $_SERVER['HTTPS'] ) != 'off' || isset( $http_host[1] ) && $http_host[1] == 443) && substr( $mosConfig_live_site, 0, 8 ) != 'https://' ) {
    $mosConfig_live_site = 'https://'.substr( $mosConfig_live_site, 7 );
}

require_once( '../includes/joomla.php' );
include_once ( $mosConfig_absolute_path . '/language/'. $mosConfig_lang .'.php' );

//Installation sub folder check, removed for work with SVN
if (file_exists( '../installation/index.php' ) && $_VERSION->SVN == 0) {
    define( '_INSTALL_CHECK', 1 );
    include ($mosConfig_absolute_path .'/offline.php');
    exit();
}

$option = strtolower( strval( mosGetParam( $_REQUEST, 'option', NULL ) ) );

// mainframe is an API workhorse, lots of 'core' interaction routines
$mainframe = new mosMainFrame( $database, $option, '..', true );

if (isset( $_POST['submit'] )) {
    $usrname    = stripslashes( mosGetParam( $_POST, 'usrname', NULL ) );
    $pass       = stripslashes( mosGetParam( $_POST, 'pass', NULL ) );

    if($pass == NULL) {
        echo "<script>alert('Please enter a password'); document.location.href='index.php?mosmsg=Please enter a password'</script>\n";
        exit();
    }

    $query = "SELECT COUNT(*)"
    . "\n FROM #__users"
    . "\n WHERE ("
    // Administrators
    . "\n gid = 24"
    // Super Administrators
    . "\n OR gid = 25"
    . "\n )"
    ;
    $database->setQuery( $query );
    $count = intval( $database->loadResult() );
    if ($count < 1) {
        mosErrorAlert( _LOGIN_NOADMINS );
    }

    $my = null;
    $query = "SELECT u.*, m.*"
    . "\n FROM #__users AS u"
    . "\n LEFT JOIN #__messages_cfg AS m ON u.id = m.user_id AND m.cfg_name = 'auto_purge'"
    . "\n WHERE u.username = " . $database->Quote( $usrname )
    . "\n AND u.block = 0"
    ;
    $database->setQuery( $query );
    $database->loadObject( $my );

    /** find the user group (or groups in the future) */
    if (@$my->id) {
        $grp            = $acl->getAroGroup( $my->id );
        $my->gid        = $grp->group_id;
        $my->usertype   = $grp->name;

        // Conversion to new type
        if ((strpos($my->password, ':') === false) && $my->password == md5($pass)) {
            // Old password hash storage but authentic ... lets convert it
            $salt = mosMakePassword(16);
            $crypt = md5($pass.$salt);
            $my->password = $crypt.':'.$salt;

            // Now lets store it in the database
            $query = 'UPDATE #__users ' .
                    'SET password = '.$database->Quote($my->password) .
                    'WHERE id = '.(int)$my->id;
            $database->setQuery($query);
            if (!$database->query()) {
                // This is an error but not sure what to do with it ... we'll still work for now
            }
        }

        list($hash, $salt) = explode(':', $my->password);
        $cryptpass = md5($pass.$salt);

        if ( strcmp( $hash, $cryptpass ) || !$acl->acl_check( 'administration', 'login', 'users', $my->usertype ) ) {
            mosErrorAlert("Incorrect Username, Password, or Access Level.  Please try again", "document.location.href='index.php'");
        }

        session_name( md5( $mosConfig_live_site ) );
        session_start();

        // construct Session ID
        $logintime  = time();
        $session_id = md5( $my->id . $my->username . $my->usertype . $logintime );


        // add Session ID entry to DB
        $query = "INSERT INTO #__session"
        . "\n SET time = " . $database->Quote( $logintime ) . ", session_id = " . $database->Quote( $session_id ) . ", userid = " . (int) $my->id . ", usertype = " . $database->Quote( $my->usertype) . ", username = " . $database->Quote( $my->username )
        ;
        $database->setQuery( $query );
        if (!$database->query()) {
            echo $database->stderr();
        }

        // check if site designated as a production site
        // for a demo site allow multiple logins with same user account
        if ( $_VERSION->SITE == 1 ) {
            // delete other open admin sessions for same account
            $query = "DELETE FROM #__session"
            . "\n WHERE userid = " . (int) $my->id
            . "\n AND username = " . $database->Quote( $my->username )
            . "\n AND usertype = " . $database->Quote( $my->usertype )
            . "\n AND session_id != " . $database->Quote( $session_id )
            // this ensures that frontend sessions are not purged
            . "\n AND guest = 1"
            . "\n AND gid = 0"
            ;
            $database->setQuery( $query );
            if (!$database->query()) {
                echo $database->stderr();
            }
        }

        $_SESSION['session_id']             = $session_id;
        $_SESSION['session_user_id']        = $my->id;
        $_SESSION['session_username']       = $my->username;
        $_SESSION['session_usertype']       = $my->usertype;
        $_SESSION['session_gid']            = $my->gid;
        $_SESSION['session_logintime']      = $logintime;
        $_SESSION['session_user_params']    = $my->params;
        $_SESSION['session_userstate']      = array();

        session_write_close();

        $expired = 'index2.php';

        // check if site designated as a production site
        // for a demo site disallow expired page functionality
        if ( $_VERSION->SITE == 1 && @$mosConfig_admin_expired === '1' ) {
            $file   = $mainframe->getPath( 'com_xml', 'com_users' );
            $params =& new mosParameters( $my->params, $file, 'component' );

            $now    = time();

            // expired page functionality handling
            $expired        = $params->def( 'expired', '' );
            $expired_time   = $params->def( 'expired_time', '' );

            // if now expired link set or expired time is more than half the admin session life set, simply load normal admin homepage
            $checktime = ( $mosConfig_session_life_admin ? $mosConfig_session_life_admin : 1800 ) / 2;
            if (!$expired || ( ( $now - $expired_time ) > $checktime ) ) {
                $expired = 'index2.php';
            }
            // link must also be a Joomla link to stop malicious redirection
            if ( strpos( $expired, 'index2.php?option=com_' ) !== 0 ) {
                $expired = 'index2.php';
            }

            // clear any existing expired page data
            $params->set( 'expired', '' );
            $params->set( 'expired_time', '' );

            // param handling
            if (is_array( $params->toArray() )) {
                $txt = array();
                foreach ( $params->toArray() as $k=>$v) {
                    $txt[] = "$k=$v";
                }
                $saveparams = implode( "\n", $txt );
            }

            // save cleared expired page info to user data
            $query = "UPDATE #__users"
            . "\n SET params = " . $database->Quote( $saveparams )
            . "\n WHERE id = " . (int) $my->id
            . "\n AND username = " . $database->Quote( $my->username )
            . "\n AND usertype = " . $database->Quote( $my->usertype )
            ;
            $database->setQuery( $query );
            $database->query();
        }

        // check if auto_purge value set
        if ( $my->cfg_name == 'auto_purge' ) {
            $purge  = $my->cfg_value;
        } else {
        // if no value set, default is 7 days
            $purge  = 7;
        }
        // calculation of past date
        $past = date( 'Y-m-d H:i:s', time() - $purge * 60 * 60 * 24 );

        // if purge value is not 0, then allow purging of old messages
        if ($purge != 0) {
        // purge old messages at day set in message configuration
            $query = "DELETE FROM #__messages"
            . "\n WHERE date_time < " . $database->Quote( $past )
            . "\n AND user_id_to = " . (int) $my->id
            ;
            $database->setQuery( $query );
            if (!$database->query()) {
                echo $database->stderr();
            }
        } 
        /** cannot using mosredirect as this stuffs up the cookie in IIS */
        // redirects page to admin homepage by default or expired page
        echo }
?>
commented: 1. For bumping a dead thread, 2,3,4,5 for continuing to post masses of code without code tags :( -6

I desperately need and answer the error code:
i got this error when i try to log in using administrator on our joomla website . your help is much appreciated.

<?php
/**
* @version $Id: index.php 8078 2007-07-19 06:45:54Z robs $
* @package Joomla
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license [url]http://www.gnu.org/copyleft/gpl.html[/url] GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// Set flag that this is a parent file
define( '_VALID_MOS', 1 );

if (!file_exists( '../configuration.php' )) {
    header( 'Location: ../installation/index.php' );
    exit();
}

require( '../globals.php' );
require_once( '../configuration.php' );

// SSL check - $http_host returns <live site url>:<port number if it is 443>
$http_host = explode(':', $_SERVER['HTTP_HOST'] );
if( (!empty( $_SERVER['HTTPS'] ) && strtolower( $_SERVER['HTTPS'] ) != 'off' || isset( $http_host[1] ) && $http_host[1] == 443) && substr( $mosConfig_live_site, 0, 8 ) != 'https://' ) {
    $mosConfig_live_site = 'https://'.substr( $mosConfig_live_site, 7 );
}

require_once( '../includes/joomla.php' );
include_once ( $mosConfig_absolute_path . '/language/'. $mosConfig_lang .'.php' );

//Installation sub folder check, removed for work with SVN
if (file_exists( '../installation/index.php' ) && $_VERSION->SVN == 0) {
    define( '_INSTALL_CHECK', 1 );
    include ($mosConfig_absolute_path .'/offline.php');
    exit();
}

$option = strtolower( strval( mosGetParam( $_REQUEST, 'option', NULL ) ) );

// mainframe is an API workhorse, lots of 'core' interaction routines
$mainframe = new mosMainFrame( $database, $option, '..', true );

if (isset( $_POST['submit'] )) {
    $usrname    = stripslashes( mosGetParam( $_POST, 'usrname', NULL ) );
    $pass       = stripslashes( mosGetParam( $_POST, 'pass', NULL ) );

    if($pass == NULL) {
        echo "<script>alert('Please enter a password'); document.location.href='index.php?mosmsg=Please enter a password'</script>\n";
        exit();
    }

    $query = "SELECT COUNT(*)"
    . "\n FROM #__users"
    . "\n WHERE ("
    // Administrators
    . "\n gid = 24"
    // Super Administrators
    . "\n OR gid = 25"
    . "\n )"
    ;
    $database->setQuery( $query );
    $count = intval( $database->loadResult() );
    if ($count < 1) {
        mosErrorAlert( _LOGIN_NOADMINS );
    }

    $my = null;
    $query = "SELECT u.*, m.*"
    . "\n FROM #__users AS u"
    . "\n LEFT JOIN #__messages_cfg AS m ON u.id = m.user_id AND m.cfg_name = 'auto_purge'"
    . "\n WHERE u.username = " . $database->Quote( $usrname )
    . "\n AND u.block = 0"
    ;
    $database->setQuery( $query );
    $database->loadObject( $my );

    /** find the user group (or groups in the future) */
    if (@$my->id) {
        $grp            = $acl->getAroGroup( $my->id );
        $my->gid        = $grp->group_id;
        $my->usertype   = $grp->name;

        // Conversion to new type
        if ((strpos($my->password, ':') === false) && $my->password == md5($pass)) {
            // Old password hash storage but authentic ... lets convert it
            $salt = mosMakePassword(16);
            $crypt = md5($pass.$salt);
            $my->password = $crypt.':'.$salt;

            // Now lets store it in the database
            $query = 'UPDATE #__users ' .
                    'SET password = '.$database->Quote($my->password) .
                    'WHERE id = '.(int)$my->id;
            $database->setQuery($query);
            if (!$database->query()) {
                // This is an error but not sure what to do with it ... we'll still work for now
            }
        }

        list($hash, $salt) = explode(':', $my->password);
        $cryptpass = md5($pass.$salt);

        if ( strcmp( $hash, $cryptpass ) || !$acl->acl_check( 'administration', 'login', 'users', $my->usertype ) ) {
            mosErrorAlert("Incorrect Username, Password, or Access Level.  Please try again", "document.location.href='index.php'");
        }

        session_name( md5( $mosConfig_live_site ) );
        session_start();

        // construct Session ID
        $logintime  = time();
        $session_id = md5( $my->id . $my->username . $my->usertype . $logintime );


        // add Session ID entry to DB
        $query = "INSERT INTO #__session"
        . "\n SET time = " . $database->Quote( $logintime ) . ", session_id = " . $database->Quote( $session_id ) . ", userid = " . (int) $my->id . ", usertype = " . $database->Quote( $my->usertype) . ", username = " . $database->Quote( $my->username )
        ;
        $database->setQuery( $query );
        if (!$database->query()) {
            echo $database->stderr();
        }

        // check if site designated as a production site
        // for a demo site allow multiple logins with same user account
        if ( $_VERSION->SITE == 1 ) {
            // delete other open admin sessions for same account
            $query = "DELETE FROM #__session"
            . "\n WHERE userid = " . (int) $my->id
            . "\n AND username = " . $database->Quote( $my->username )
            . "\n AND usertype = " . $database->Quote( $my->usertype )
            . "\n AND session_id != " . $database->Quote( $session_id )
            // this ensures that frontend sessions are not purged
            . "\n AND guest = 1"
            . "\n AND gid = 0"
            ;
            $database->setQuery( $query );
            if (!$database->query()) {
                echo $database->stderr();
            }
        }

        $_SESSION['session_id']             = $session_id;
        $_SESSION['session_user_id']        = $my->id;
        $_SESSION['session_username']       = $my->username;
        $_SESSION['session_usertype']       = $my->usertype;
        $_SESSION['session_gid']            = $my->gid;
        $_SESSION['session_logintime']      = $logintime;
        $_SESSION['session_user_params']    = $my->params;
        $_SESSION['session_userstate']      = array();

        session_write_close();

        $expired = 'index2.php';

        // check if site designated as a production site
        // for a demo site disallow expired page functionality
        if ( $_VERSION->SITE == 1 && @$mosConfig_admin_expired === '1' ) {
            $file   = $mainframe->getPath( 'com_xml', 'com_users' );
            $params =& new mosParameters( $my->params, $file, 'component' );

            $now    = time();

            // expired page functionality handling
            $expired        = $params->def( 'expired', '' );
            $expired_time   = $params->def( 'expired_time', '' );

            // if now expired link set or expired time is more than half the admin session life set, simply load normal admin homepage
            $checktime = ( $mosConfig_session_life_admin ? $mosConfig_session_life_admin : 1800 ) / 2;
            if (!$expired || ( ( $now - $expired_time ) > $checktime ) ) {
                $expired = 'index2.php';
            }
            // link must also be a Joomla link to stop malicious redirection
            if ( strpos( $expired, 'index2.php?option=com_' ) !== 0 ) {
                $expired = 'index2.php';
            }

            // clear any existing expired page data
            $params->set( 'expired', '' );
            $params->set( 'expired_time', '' );

            // param handling
            if (is_array( $params->toArray() )) {
                $txt = array();
                foreach ( $params->toArray() as $k=>$v) {
                    $txt[] = "$k=$v";
                }
                $saveparams = implode( "\n", $txt );
            }

            // save cleared expired page info to user data
            $query = "UPDATE #__users"
            . "\n SET params = " . $database->Quote( $saveparams )
            . "\n WHERE id = " . (int) $my->id
            . "\n AND username = " . $database->Quote( $my->username )
            . "\n AND usertype = " . $database->Quote( $my->usertype )
            ;
            $database->setQuery( $query );
            $database->query();
        }

        // check if auto_purge value set
        if ( $my->cfg_name == 'auto_purge' ) {
            $purge  = $my->cfg_value;
        } else {
        // if no value set, default is 7 days
            $purge  = 7;
        }
        // calculation of past date
        $past = date( 'Y-m-d H:i:s', time() - $purge * 60 * 60 * 24 );

        // if purge value is not 0, then allow purging of old messages
        if ($purge != 0) {
        // purge old messages at day set in message configuration
            $query = "DELETE FROM #__messages"
            . "\n WHERE date_time < " . $database->Quote( $past )
            . "\n AND user_id_to = " . (int) $my->id
            ;
            $database->setQuery( $query );
            if (!$database->query()) {
                echo $database->stderr();
            }
        } 
        /** cannot using mosredirect as this stuffs up the cookie in IIS */
        // redirects page to admin homepage by default or expired page
        echo }
?>

Well what was the error? Did the computer explode or did the page just not load. If any error messages popped up please post them.

Well what was the error? Did the computer explode or did the page just not load. If any error messages popped up please post them.

Hi sir,

here's the error:

Parse error: syntax error, unexpected $end in /hermes/web05/b1461/pow.walterng/htdocs/esprintsolutions/administrator/index.php on line 230


that's the code i indicated previously on my index.php

according to other forums : something to do with the syntax:

" <?php "

im not a techie on programming stuff , hope you could advise . thanks so much.

Well that error normally refers to not enough ending brackets } or even too many before the end of the script. I just checked your script and there is a bug on the second last line. It looks like you are trying to echo a bracket and when counting the brackets there aren't enough closing brackets before the script ends. So try making the last two lines the following:

} }
?>

Well that error normally refers to not enough ending brackets } or even too many before the end of the script. I just checked your script and there is a bug on the second last line. It looks like you are trying to echo a bracket and when counting the brackets there aren't enough closing brackets before the script ends. So try making the last two lines the following:

} }
?>

i tried what you have suggested sir bu still i get same error. would appreciate your patience and help sir.

thanks

Well I would suggest placing the code into a live syntax highlighter such as notepad++ and check each bracket associated with each if statement to see which if statements need to have a closing bracket added. That is where the problem is as I can see it but am not sure where you would like those closing brackets and exactly how many closing brackets do need adding. An example in your code is the if statement if (isset( $_POST['submit'] )) is does not have a closing bracket.

Well I would suggest placing the code into a live syntax highlighter such as notepad++ and check each bracket associated with each if statement to see which if statements need to have a closing bracket added. That is where the problem is as I can see it but am not sure where you would like those closing brackets and exactly how many closing brackets do need adding. An example in your code is the if statement if (isset( $_POST['submit'] )) is does not have a closing bracket.

thanks,

now i got different problem. the password button keeps popping up. added 2 braces and this is the new code: derately needs help.

you can check my web: esprint.org/administrator

<?php
/**
* @version $Id: index.php 8078 2007-07-19 06:45:54Z robs $
* @package Joomla
* @copyright Copyright (C) 2005 Open Source Matters. All rights reserved.
* @license [url]http://www.gnu.org/copyleft/gpl.html[/url] GNU/GPL, see LICENSE.php
* Joomla! is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/

// Set flag that this is a parent file
define( '_VALID_MOS', 1 );

if (!file_exists( '../configuration.php' )) {
    header( 'Location: ../installation/index.php' );
    exit();
}

require( '../globals.php' );
require_once( '../configuration.php' );

// SSL check - $http_host returns <live site url>:<port number if it is 443>
$http_host = explode(':', $_SERVER['HTTP_HOST'] );
if( (!empty( $_SERVER['HTTPS'] ) && strtolower( $_SERVER['HTTPS'] ) != 'off' || isset( $http_host[1] ) && $http_host[1] == 443) && substr( $mosConfig_live_site, 0, 8 ) != 'https://' ) {
    $mosConfig_live_site = 'https://'.substr( $mosConfig_live_site, 7 );
}

require_once( '../includes/joomla.php' );
include_once ( $mosConfig_absolute_path . '/language/'. $mosConfig_lang .'.php' );

//Installation sub folder check, removed for work with SVN
if (file_exists( '../installation/index.php' ) && $_VERSION->SVN == 0) {
    define( '_INSTALL_CHECK', 1 );
    include ($mosConfig_absolute_path .'/offline.php');
    exit();
}

$option = strtolower( strval( mosGetParam( $_REQUEST, 'option', NULL ) ) );

// mainframe is an API workhorse, lots of 'core' interaction routines
$mainframe = new mosMainFrame( $database, $option, '..', true );

if (isset( $_POST['submit'] )) {
    $usrname    = stripslashes( mosGetParam( $_POST, 'usrname', NULL ) );
    $pass       = stripslashes( mosGetParam( $_POST, 'pass', NULL ) );
}
    if($pass == NULL) {
        echo "<script>alert('Please enter a password'); document.location.href='index.php?mosmsg=Please enter a password'</script>\n";{
        exit();
    }


    $query = "SELECT COUNT(*)"
    . "\n FROM #__users"
    . "\n WHERE ("
    // Administrators
    . "\n gid = 24"
    // Super Administrators
    . "\n OR gid = 25"
    . "\n )"
    ;
    $database->setQuery( $query );
    $count = intval( $database->loadResult() );
    if ($count < 1) {
        mosErrorAlert( _LOGIN_NOADMINS );
    }

    $my = null;
    $query = "SELECT u.*, m.*"
    . "\n FROM #__users AS u"
    . "\n LEFT JOIN #__messages_cfg AS m ON u.id = m.user_id AND m.cfg_name = 'auto_purge'"
    . "\n WHERE u.username = " . $database->Quote( $usrname )
    . "\n AND u.block = 0"
    ;
    $database->setQuery( $query );
    $database->loadObject( $my );

    /** find the user group (or groups in the future) */
    if (@$my->id) {
        $grp            = $acl->getAroGroup( $my->id );
        $my->gid        = $grp->group_id;
        $my->usertype   = $grp->name;

        // Conversion to new type
        if ((strpos($my->password, ':') === false) && $my->password == md5($pass)) {
            // Old password hash storage but authentic ... lets convert it
            $salt = mosMakePassword(16);
            $crypt = md5($pass.$salt);
            $my->password = $crypt.':'.$salt;

            // Now lets store it in the database
            $query = 'UPDATE #__users ' .
                    'SET password = '.$database->Quote($my->password) .
                    'WHERE id = '.(int)$my->id;
            $database->setQuery($query);
            if (!$database->query()) {
                // This is an error but not sure what to do with it ... we'll still work for now
            }
        }

        list($hash, $salt) = explode(':', $my->password);
        $cryptpass = md5($pass.$salt);

        if ( strcmp( $hash, $cryptpass ) || !$acl->acl_check( 'administration', 'login', 'users', $my->usertype ) ) {
            mosErrorAlert("Incorrect Username, Password, or Access Level.  Please try again", "document.location.href='index.php'");
        }

        session_name( md5( $mosConfig_live_site ) );
        session_start();

        // construct Session ID
        $logintime  = time();
        $session_id = md5( $my->id . $my->username . $my->usertype . $logintime );


        // add Session ID entry to DB
        $query = "INSERT INTO #__session"
        . "\n SET time = " . $database->Quote( $logintime ) . ", session_id = " . $database->Quote( $session_id ) . ", userid = " . (int) $my->id . ", usertype = " . $database->Quote( $my->usertype) . ", username = " . $database->Quote( $my->username )
        ;
        $database->setQuery( $query );
        if (!$database->query()) {
            echo $database->stderr();
        }

        // check if site designated as a production site
        // for a demo site allow multiple logins with same user account
        if ( $_VERSION->SITE == 1 ) {
            // delete other open admin sessions for same account
            $query = "DELETE FROM #__session"
            . "\n WHERE userid = " . (int) $my->id
            . "\n AND username = " . $database->Quote( $my->username )
            . "\n AND usertype = " . $database->Quote( $my->usertype )
            . "\n AND session_id != " . $database->Quote( $session_id )
            // this ensures that frontend sessions are not purged
            . "\n AND guest = 1"
            . "\n AND gid = 0"
            ;
            $database->setQuery( $query );
            if (!$database->query()) {
                echo $database->stderr();
            }
        }

        $_SESSION['session_id']             = $session_id;
        $_SESSION['session_user_id']        = $my->id;
        $_SESSION['session_username']       = $my->username;
        $_SESSION['session_usertype']       = $my->usertype;
        $_SESSION['session_gid']            = $my->gid;
        $_SESSION['session_logintime']      = $logintime;
        $_SESSION['session_user_params']    = $my->params;
        $_SESSION['session_userstate']      = array();

        session_write_close();

        $expired = 'index2.php';

        // check if site designated as a production site
        // for a demo site disallow expired page functionality
        if ( $_VERSION->SITE == 1 && @$mosConfig_admin_expired === '1' ) {
            $file   = $mainframe->getPath( 'com_xml', 'com_users' );
            $params =& new mosParameters( $my->params, $file, 'component' );

            $now    = time();

            // expired page functionality handling
            $expired        = $params->def( 'expired', '' );
            $expired_time   = $params->def( 'expired_time', '' );

            // if now expired link set or expired time is more than half the admin session life set, simply load normal admin homepage
            $checktime = ( $mosConfig_session_life_admin ? $mosConfig_session_life_admin : 1800 ) / 2;
            if (!$expired || ( ( $now - $expired_time ) > $checktime ) ) {
                $expired = 'index2.php';
            }
            // link must also be a Joomla link to stop malicious redirection
            if ( strpos( $expired, 'index2.php?option=com_' ) !== 0 ) {
                $expired = 'index2.php';
            }

            // clear any existing expired page data
            $params->set( 'expired', '' );
            $params->set( 'expired_time', '' );

            // param handling
            if (is_array( $params->toArray() )) {
                $txt = array();
                foreach ( $params->toArray() as $k=>$v) {
                    $txt[] = "$k=$v";
                }
                $saveparams = implode( "\n", $txt );
            }
            // save cleared expired page info to user data
            $query = "UPDATE #__users"
            . "\n SET params = " . $database->Quote( $saveparams )
            . "\n WHERE id = " . (int) $my->id
            . "\n AND username = " . $database->Quote( $my->username )
            . "\n AND usertype = " . $database->Quote( $my->usertype )
            ;
            $database->setQuery( $query );
            $database->query();
        }

        // check if auto_purge value set
        if ( $my->cfg_name == 'auto_purge' ) {
            $purge  = $my->cfg_value;
        } else {
        // if no value set, default is 7 days
            $purge  = 7;
        }
        // calculation of past date
        $past = date( 'Y-m-d H:i:s', time() - $purge * 60 * 60 * 24 );

        // if purge value is not 0, then allow purging of old messages
        if ($purge != 0) {
        // purge old messages at day set in message configuration
            $query = "DELETE FROM #__messages"
            . "\n WHERE date_time < " . $database->Quote( $past )
            . "\n AND user_id_to = " . (int) $my->id
            ;
            $database->setQuery( $query );
            if (!$database->query()) {
                echo $database->stderr();
            }
        }
        }
        }


        /** cannot using mosredirect as this stuffs up the cookie in IIS
        * redirects page to admin homepage by default or expired page echo "
        */
?>

Well that error normally refers to not enough ending brackets } or even too many before the end of the script. I just checked your script and there is a bug on the second last line. It looks like you are trying to echo a bracket and when counting the brackets there aren't enough closing brackets before the script ends. So try making the last two lines the following:

} }
?>

got the solution already. thanks sir.

I think the problem is here
'<?region-start id="lines" type="repeat" ?>';

You need to have
'<?php region-start id="lines" type="repeat" ?>';

Jeez how many times can this thing get bumped? It's almost 3 years old!!!

   <?php
    //Start session
    session_start();

    //Include database connection details
    require_once('config.php');

    //Array to store validation errors
    $errmsg_arr = array();

    //Validation error flag
    $errflag = false;

    //Connect to mysql server
    $link = mysql_connect(DB_HOST,DB_USER, DB_PASSWORD);
    if(!$link) {
        die('Failed to connect to server: ' . mysql_error());
    }

    //Select database
    $db = mysql_select_db(DB_DATABASE);
    if(!$db) {
        die("Unable to select database");
    }

    //Function to sanitize values received from the form. Prevents SQL 

injection
    function clean($str) {
        $str = @trim($str);
        if(get_magic_quotes_gpc()) {
            $str = stripslashes($str);
        }
        return mysql_real_escape_string($str);
    }

    //Sanitize the POST values
    $firstname = clean($_POST['First Name']);
    $lastname = clean($_POST['Last Name']);
    $login = clean($_POST['Login']);
    $passwd = clean($_POST['Password']);
    $Conform Password = clean($_POST['Conform Password']);
    $Email_Id = clean($_POST['Email_Id']);
    $Address Line-1 = clean($_POST['Address Line-1']);
    $Address Line-2 = clean($_POST['Address Line-2']);
    $Country = clean($_POST['Country']);
    $City = clean($_POST['City']);
    $State = clean($_POST['State']);
    $Phone No. = clean($_POST['Phone No.']);
    $Mobile No. = clean($_POST['Mobile No.']);
    $Age = clean($_POST['Age']);
    $Gender = clean($_POST['Gender']);
    $Till Date Shoopping Amount = clean($_POST['Till Date  Shopping Amount']);
    $Points = clean($_POST['Points']);
    $Income = clean($_POST['Income']);
    $Comment = clean($_POST['Comment']);





    //Input Validations
    if($firstname == '') {
        $errmsg_arr[] = 'First Name Missing';
        $errflag = true;
    }
    if($lastname == '') {
        $errmsg_arr[] = 'Last Name Missing';
        $errflag = true;
    }
    if($login == '') {
        $errmsg_arr[] = 'Login Id Missing';
        $errflag = true;
    }
    if($passwd == '') {
        $errmsg_arr[] = 'Password Missing';
        $errflag = true;
    }
    if($Conform Password == '') {
        $errmsg_arr[] = 'Confirm Password Missing';
        $errflag = true;
    }
    if($Email_Id== '' ){
      $errmsg_arr[] = 'Enter vaild EmailID';
      $errflg = true;
    }
    if($Address Line-1 ==''){
      $errmsg_arr[] = 'Please Enter Your Address';
      $errflag = true;
    }
     if($Address Line-2 ==''){
      $errmsg_arr[] = 'Please Enter Your Address';
      $errflag = true;
    }
     if($Country ==''){
      $errmsg_arr[] = 'Please Select Your Country';
      $errflag = true;
    }
     if($City ==''){
      $errmsg_arr[] = 'Please Enter Your City Name';
      $errflag = true;
    }
     if($State ==''){
      $errmsg_arr[] = 'Please Select Your State';
      $errflag = true;
    }
     if($Phone No. ==''){
      $errmsg_arr[] = 'Please Enter Your Phone No.';
      $errflag = true;
    }
     if($Mobile No. ==''){
      $errmsg_arr[] = 'Please Enter Your Mobile No.';
      $errflag = true;
    }
    if($Age ==''){
      $errmsg_arr[] = 'Please Select age ';
      $errflag = true;
    }
     if($Gender ==''){
      $errmsg_arr[] = 'Please Select sex ';
      $errflag = true;
    }

     if($Till Date Shopping Amount ==''){
      $errmsg_arr[] = '';
      $errflag = False;
    }
     if($Points ==''){
      $errmsg_arr[] = 'Please Enter Your Address';
      $errflag = false;
    }
     if($Income ==''){
      $errmsg_arr[] = 'Please Enter Your Address';
      $errflag = false;
    }
     if($Comment ==''){
      $errmsg_arr[] = 'Please Enter Your Address';
      $errflag = False;
    }

    if( strcmp($password, $conformpassword) != 0 ) {
        $errmsg_arr[] = 'Passwords do not match';
        $errflag = true;
    }


    //Check for duplicate login ID
    if($login != '') {
        $qry = "SELECT * FROM members WHERE login=''";
        $result = mysql_query($qry);
        if($result) {
            if(mysql_num_rows($result) > 0) {
                $errmsg_arr[] = 'Login ID already in use';
                $errflag = true;
            }
            @mysql_free_result($result);
        }
        else {
            die("Query failed");
        }
    }

    //If there are input validations, redirect back to the registration form
    if($errflag) {
        $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
        session_write_close();
        header("location: register-success.php");
        exit();
    }

    //Create INSERT query
    $qry = "INSERT INTO members(First Name, Last Name, Password, Conform 

Password, Email_id, Address Line-1, Address Line-2, Country, City, State, Phone 

No., Mobile No., Age, Gender, Till Date Shopping Amount , Income, Comment) 

VALUES('$firstname,'$lastname','','".md5($_POST['password'])."','$conformpassword',

'$email_id','$addressline1','$addressline2','$country','$city','$state_id','$phonen

o''$mobileno','$age','$gender','$till_date','$income','$comment_id')";
    $result = @mysql_query($qry);

    //Check whether the query was successful or not
    if($result) {
        header("location: member.php");
        exit();
    }else {
        die("Query failed");
    }
?>

I have the syntax error. Parse error: syntax error, unexpected T_STRING in Line 1.

<?xml version="1.0" encoding="utf-8" ?>

Hi, i need assistance to debug this:
Whenever i run this script, it shows this error message:

Parse error: syntax error, unexpected T_STRING in /home/nialsalu/public_html/swifttide/admin_contact_2.php on line 53

The php codes are:

<?php
//*
// admin_contact_2.php
// Admin Section
// Search and display list of results or redirect to page to display single result
//*
// Version 1.0, 2007-05-224
// Doug allow editing, Yes or No for active, sep 07
//
//Check if admin is logged in
session_start();
if(!isset($_SESSION['UserID']) || $_SESSION['UserType'] != "A")
  {
    header ("Location: index.php?action=notauth");
    exit;
}

//Include global functions
include_once "common.php";
//Initiate database functions
include_once "ez_sql.php";
//Include paging class
include_once "ez_results.php";
// config
include_once "configuration.php";
$msgFormErr="";

//Get search field info
$action=get_param("action");

//Special field-defines teachers as active
$active="Y";

//Determine what field(s) to search
switch ($action){

    case "searchcontacts":
        $contactid=get_param("contactid");
        if ($contactid == "") {
        $sSQL = "SELECT web_users_id, web_users_flname, active 
        FROM web_users 
        WHERE web_users_type = 'C'";
        } else {
        $sSQL = "SELECT web_users_id, web_users_flname, active 
        FROM web_users 
        WHERE web_users_relid = '$contactid' 
        AND web_users_type = 'C'"; }
        if($cont = $db->get_row($sSQL)){
            //Set paging appearence
            $ezr->results_open = "<table width=100% cellpadding=2 cellspacing=0 border=1>";
            $ezr->results_close = "</table>";
            $ezr->results_heading = "<tr class=tblhead>"
            <td width=30%>" Name" </td>
            <td width=10%>""Active";"</td>
            <td width=20%>&nbsp;</td>
            <td width=20%>&nbsp;</td>
            <td width=20%>&nbsp;</td>
            </tr>";
            $ezr->results_row = "<tr class=tblcont>
            <td class=paging width=30%>COL2</td>
            <td class=paging width=10% align=center>COL3</td>
            <td class=paging width=20% align=center>
              <a href=admin_webusers_active.php?act=1&from=conta&contactid=COL1 class=aform>
              &nbsp;" . "Activate"; . "</td>
            <td class=paging width=20% align=center>
              <a href=admin_webusers_active.php?act=0&from=conta&contactid=COL1 class=aform>
              &nbsp;" . "Deactivate"; . "</td>
            <td class=paging width=20% align=center>
              <a href=admin_contact_webusers.php?act=edit&contactid=COL1 class=aform>&nbsp;" . "Edit"; . "</td>
            </tr>";
            $ezr->query_mysql($sSQL);
        }else{
            $msgFormErr="Contact not found";;
        };
        break;
    case "searchlname":
        $cname=get_param("cname");
        $sSQL = "SELECT web_users_id, web_users_flname, active 
        FROM (web_users 
        INNER JOIN studentcontact ON studentcontact_id = web_users_relid) 
        WHERE studentcontact_lname = '$cname' 
        AND web_users_type = 'C'";
        if ($cont = $db->get_row($sSQL)) {
            //Set paging appearence
            $ezr->results_open = "<table width=100% cellpadding=2 cellspacing=0 border=1>";
            $ezr->results_close = "</table>";
            $ezr->results_heading = "<tr class=tblhead>
              <td width=30%>" . "Name"; . "</td>
              <td width=30%>" . "Active"; . "</td>
              <td width=20%>&nbsp;</td>
              <td width=20%>&nbsp;</td>
            </tr>";
            $ezr->results_row = "<tr class=tblcont>
            <td class=paging width=30%>COL2</td>
            <td class=paging width=30% align=center>COL3</td>
            <td class=paging width=20% align=center>
              <a href=admin_webusers_active.php?act=1&contactid=COL1 class=aform>
              &nbsp;" . "Activate"; . "</td>
            <td class=paging width=20% align=center>
              <a href=admin_webusers_active.php?act=0&contactid=COL1 class=aform>
              &nbsp;" . "Deactivate"; . "</td>
            </tr>";
            $ezr->query_mysql($sSQL);

            $ezr->set_qs_val("cname", $cname);
            $ezr->set_qs_val("action", "searchlname"); 
        }else{
            $msgFormErr="Contact not found: "; . $cname;
        };
        break;
    case "letter":
        $letter=get_param("letter");
        $sSQL = "SELECT web_users_id, web_users_flname, active 
        FROM web_users 
        INNER JOIN studentcontact ON web_users_relid = studentcontact_id 
        WHERE studentcontact_lname LIKE '$letter%' 
        AND web_users_type = 'C'";
        if ($cont = $db->get_row($sSQL)) {
            //Set paging appearence
            $ezr->results_open = "<table width=100% cellpadding=2 cellspacing=0 border=1>";
            $ezr->results_close = "</table>";
            $ezr->results_heading = "<tr class=tblhead>
            <td width=30%>" . "Name"; . "</td>
            <td width=30%>" . "Active"; . "</td>
            <td width=20%>&nbsp;</td>
            <td width=20%>&nbsp;</td>
            </tr>";
            $ezr->results_row = "<tr class=tblcont>
            <td class=paging width=30%>COL2</td>
            <td class=paging width=30% align=center>COL3</td>
            <td class=paging width=20% align=center>
              <a href=admin_webusers_active.php?act=1&contactid=COL1 class=aform>
              &nbsp;" . "Activate"; . "</td>
            <td class=paging width=20% align=center>
              <a href=admin_webusers_active.php?act=0&contactid=COL1 class=aform>
              &nbsp;" . "Deactivate"; . "</td>
            </tr>";
            $ezr->query_mysql($sSQL);

            $ezr->set_qs_val("letter", $letter);
            $ezr->set_qs_val("action", "letter"); 
        }else{
            $msgFormErr="Contact not found: Letter "; . $letter;
        };
        break;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<title><?php echo "School Management System";?></title>
<style type="text/css" media="all">@import "student-admin.css";</style>
<SCRIPT language="JavaScript">
/* Javascript function to ask confirmation before removing record */
function cnfremove(id) {
        var answer;
    answer = window.confirm("<?php echo _ADMIN_CONTACT_2_SURE?>");
    if (answer == 1) {
        var url;
        url = "admin_teacher_1.php?action=remove&teacherid=" + id;
        window.location = url; // other browsers
        href_remove.href = url; // explorer
    }
    return false;
}
</SCRIPT>

<script type="text/javascript" language="JavaScript" src="sms.js"></script>
<link rel="icon" href="favicon.ico" type="image/x-icon"><link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
</head>

<body><img src="images/<?php echo _LOGO?>" border="0">

<div id="Header">
<table width="100%">
  <tr>
    <td width="50%" align="left"><font size="2">&nbsp;&nbsp;<?php echo date("l F j, Y"); ?></font></td>
    <td width="50%"><?php echo "Administrator Area";?></td>
  </tr>
</table>
</div>

<div id="Content">
    <h1><?php echo "Teacher Search Result";?></h1>
    <br>
    <?php
    if (strlen($msgFormErr)){
        //No results
    ?>
        <h3><?php echo $msgFormErr; ?></h3>
    <?php
    }else{
        //Dislay results with paging options
        $ezr->display();
    };
    ?>
    <br>
    <a class="aform" href="admin_users_1.php"><?php echo "New Search";?></a>
</div>
<?php 
include "admin_menu.inc.php";?>
</body>

</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.