Forums

DB Connectivity

mr_bell 11 Jan, 2010
I am trying to get a multi page from to hook up to a database, it creates the table for entries fine. When you connect the form to the datbase I get the following error;

"Parse error: parse error, expecting `T_VARIABLE' in C:\wamp\www\ratcliffes15\components\com_chronocontact\chronocontact.php(53) : eval()'d code on line 77"

I'm guessing its something to do with the autogenterated code but I not sure how this should work the auto-gen code is set to the following;


<?php
		$MyForm =& CFChronoForm::getInstance("direct_commgit");
		if($MyForm->formparams("dbconnection") == "Yes"){
			$user = JFactory::getUser();			
			$row =& JTable::getInstance("chronoforms_direct_commgit", "Table");
			srand((double)microtime()*10000);
			$inum	=	"I" . substr(base64_encode(md5(rand())), 0, 16).md5(uniqid(mt_rand(), true));
			JRequest::setVar( "recordtime", JRequest::getVar( "recordtime", date("Y-m-d")." - ".date("H:i:s"), "post", "string", "" ));
			JRequest::setVar( "ipaddress", JRequest::getVar( "ipaddress", $_SERVER["REMOTE_ADDR"], "post", "string", "" ));
			JRequest::setVar( "uid", JRequest::getVar( "uid", $inum, "post", "string", "" ));
			JRequest::setVar( "cf_user_id", JRequest::getVar( "cf_user_id", $user->id, "post", "int", "" ));
			$post = JRequest::get( "post" , JREQUEST_ALLOWRAW );			
			if (!$row->bind( $post )) {
				JError::raiseWarning(100, $row->getError());
			}				
			if (!$row->store()) {
				JError::raiseWarning(100, $row->getError());
			}
			$MyForm->tablerow["jos_chronoforms_direct_commgit"] = $row;
		}
		?>
		
GreyHead 11 Jan, 2010
Hi mr_bell,

You probably have a dash '-', or a space or some other special character in one of your input names??

Bob
mr_bell 11 Jan, 2010
I have checked them due to past posts suggesting that this could cause an issue. When you say input names will it look in the form for these or for the various columns in the table you connect to?
GreyHead 11 Jan, 2010
Hi mr_bell,

ChronoForms creates a Table Class with the names of the columns from the database table and saves it in the Database. This class is then used to save the form data.

The error is showing up from line 77 of the saved class. Typically this would be a column name that isn't parsing correctly in PHP.

Bob
mr_bell 12 Jan, 2010
Can you point me in the direction of where I can see this class that it creates in the database so I can check for foreign characters?
mr_bell 12 Jan, 2010
Think I found the issue I had names starting with a number and I don't think it likes them e.g.

$var $1_DriverType4 = null;

For anyone intrested you can find a column in your db called "dbclasses" in there you will find the list of fields it has added to the class makes it easy to debug if you add it to a text editor to see line numbers to pick out where your issue lies :-)
GreyHead 12 Jan, 2010
Hi mr_bell,

Yes, that would cause the problem, but I didn't think of it :-(

PHP variables, like HTML input names are [a-z], [A-Z], [0-9], '_' but may not start with a number or contain any spaces or special characters except the underscore. In ChronoForms MySQL table column names are used as PHP variables so the same rules apply.

Bob
This topic is locked and no more replies can be posted.