Forums

Odd T_string error

Acario 15 Nov, 2009
First off, I want to say thanks for such a wonderful app. I've tried JForms, and found it's customization lacking. ChronoForms is so much more versatile.

Now the problem I'm having is kind of weird. It's got something to do with writing to the database.

Here is the error message I am getting:

Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/www/imperialarmy.info/components/com_chronocontact/chronocontact.php(53) : eval()'d code on line 12



The issue occurs both with custom code, as well as no custom code. Turning off "save to database" clears the error. I've also deleted to database table and started from scratch.

Here is the code that is in the chronocontact.php:
<?php
/**
 * CHRONOFORMS version 3.1
 * Copyright (c) 2006 Chrono_Man, ChronoEngine.com. All rights reserved.
 * Author: Chrono_Man (ChronoEngine.com)
 * See readme.html.
 * @license		GNU/GPL
 * Visit http://www.ChronoEngine.com for regular update and information.
 **/

/* ensure that this file is called by another file */
defined('_JEXEC') or die('Restricted access');

/**
 * Load the HTML class
 */
require_once( JApplicationHelper::getPath( 'front_html' ) );
require_once( JApplicationHelper::getPath( 'class' ) );

require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
//load chronoforms classes
require_once( JPATH_COMPONENT.DS.'libraries'.DS.'chronoform.php');
require_once( JPATH_COMPONENT.DS.'libraries'.DS.'mails.php');
require_once( JPATH_COMPONENT.DS.'libraries'.DS.'customcode.php');
require_once( JPATH_COMPONENT.DS.'libraries'.DS.'chronoformuploads.php');
require_once( JPATH_COMPONENT.DS.'libraries'.DS.'plugins.php');




jimport( 'joomla.application.component.controller' );
global $mainframe;
if(JRequest::getVar('chronoformname')){
	JRequest::setVar('chronoformname', preg_replace('/[^A-Za-z0-9_]/', '', JRequest::getVar('chronoformname')));
}
$formname = JRequest::getVar('chronoformname');
if ( !$formname ) {
	$params =& $mainframe->getPageParameters('com_chronocontact');
	$formname = $params->get('formname');
}

$MyForm =& CFChronoForm::getInstance($formname);

if(!$MyForm->formrow->id){
	echo "There is no form with this name or may be the form is unpublished, Please check the form and the url and the form management";
	return;
}

if($MyForm->formparams('dbconnection') == "Yes"){
	eval ("?>".$MyForm->formrow->dbclasses);
}

$posted = JRequest::get( 'post' , JREQUEST_ALLOWRAW );
/**
 * Main switch statement
 */
switch( $task ) {
	case 'send':
		uploadandmail($formname);
		break;
	case 'extra':
		doextratask($formname);
		break;
	default:
		showform($formname, $posted);
		break;
}
/**
 * End of main page
 *
 */

/**
 * Display the form for entry
 *
 */
function showform($formname, $posted)
{
    global $mainframe;
	$database =& JFactory::getDBO();

    $MyForm =& CFChronoForm::getInstance($formname);
	$MyForm->showForm($formname, $posted);
    //HTML_ChronoContact::showform( $MyForm->formrow, $posted);
}

/**
 * Respond to a submitted form
 *
 */
function uploadandmail($formname)
{
    global $mainframe;
	$database =& JFactory::getDBO();
	$posted = JRequest::get( 'post' , JREQUEST_ALLOWRAW );
	
	//Load Chronoforms Classes
    $MyForm =& CFChronoForm::getInstance($formname);
	$MyFormData = $MyForm->getForm(JRequest::getVar( 'chronoformname'));
	if($MyFormData){
		//fine
	}else{
		$mainframe->enqueueMessage('Error processing this form, form was not loaded!');
		return;
	}
	
	// Block SPAM through the submit URL
	if((!JRequest::checkToken()) && $MyForm->formparams('checkToken', 1)){
		echo "You are not allowed to access this URL";
		return;
	}
	if ( empty($posted) ) {
		echo "You are not allowed to access this URL directly, POST array is empty";
		return;
	}	
	
	if(JRequest::getVar('action') == 'extra'){
		$extraid = JRequest::getVar( 'extraid');
		$MyForm->doExtra($MyForm->formrow->name, $extraid, $posted);
	}
	
	$MyForm->submitForm($MyForm->formrow->name, $posted, $MyForm->formparams('useCurrent', false));
}

function doextratask($formname){
	global $mainframe;
	$database =& JFactory::getDBO();
	$posted = JRequest::get( 'post' , JREQUEST_ALLOWRAW );
	
    $MyForm =& CFChronoForm::getInstance($formname);
	$extraid = JRequest::getVar( 'extraid');
	$MyForm->doExtra($formname, $extraid, $posted);
}
?>


Any assistance is appreciated, even pointing me in the right direction.
nml375 15 Nov, 2009
Hi,
The 53rd line of chronocontact.php loads the custom JTable-class ChronoForm uses for the DB Connection. This kind of error would usually suggest there are some inappropriate characters in the table field names, which breaks the code. For reliable operation, only use a-Z, 0-9 and underscore (_) in these names.
Remember to re-create the connection once you've modified your database table, as the dbclasses-code isn't updated otherwize.

/Fredrik
Acario 16 Nov, 2009
ok thanks, I'll take a look at it.
Acario 16 Nov, 2009
The name of the table is: jos_chronoforms_memberapplication

Table field names:

cf_id
uid
recordtime
ipaddress
cf_user_id
PrimaryCharacter
Primary_Class
Alternate_Classes
Real_ Life_Age
Location
Timezone
Former_guilds
References
Play_times
Game_length_time
Applying_to_other_guilds
Apply_what_other_guilds
Why_do_you_want_to_join
Character_goals
Attracted_to_IA
Bring_to_ia
Share_account
Why_share_account
I_agree



Far as I can tell, these are all valid characters in the names. Anything else I should look into?
nml375 16 Nov, 2009
Hi,
There's a space in "Real_ Life_Age", which is not a permitted character.

If this does not solve the issue, could you use some DB-tools (such as phpmyadmin or other), and retrieve the content of the dbclasses field in the jos_chronocontact table, then post it here?

/Fredrik
Acario 16 Nov, 2009
THANKS!!!

I removed the space and all is well. I can't believe I had overlooked something so simple. Thanks for the help.
This topic is locked and no more replies can be posted.