Incorrect XML Error using dhtmlxform

I’m getting an ‘Incorrect XML’ error using the dhtmlxform beta. This occurs when the .load() method is called. Calling data.php?id=1 directly in the browser generates well formed XML:

I have enabled the log option in data.php. The log is not written to when the .load() method is called, but it is written to when data.php is called directly.

Thanks

Can you provide exact code of load command, as it was used in the problematic case?

This is the HTML (01_load.html):

[b]

dhtmlxForm sample
<style type="text/css" media="screen">
	div {
		width:350px;
		height:30px;
	}
	div input {
		float:right;
		width:250px;
	}
	.dhxlist_obj_dhx_skyblue label{
		color:#000000;
		font-family:Tahoma;
		font-size:11px;
	}
	.dhxlist_obj_dhx_skyblue .dhxlist_txt_textarea, input.dhtmlx_validation_error{
		border: 1px solid #A4BED4;
		padding: 1px 0;
	}
</style>
Package:
Version:
Package size:
Maintainer:
<script>
	var myForm = new dhtmlXForm("my_form","php/data.php");
</script>
<input type="button" name="" value="load data #1" onclick="myForm.load('1');"> 
<input type="button" name="" value="load data #2" onclick="myForm.load('2');"> 
<input type="button" name="" value="load data #5" onclick="myForm.load('5');">
[/b]

This is the PHP (data.php):

[b]<?php
require_once(’…/…/common/config.php’);
require_once(’…/…/…/codebase/connector/form_connector.php’);

// sleep(1);

$form = new FormConnector($conn);
$form->enable_log("log.txt");
$form->render_table("packages_plain","Id","Package,Version,Size,Maintainer");

?>[/b]

The config.php file has, of course, been amended with the details of the MySQL database.

Which version of dhtmlxform you are using?

While version, which was published in blog must work correctly with such syntax, the updated one, which was posted on forum, will require different syntax.

old one
var myForm = new dhtmlXForm(“my_form”,“php/data.php”);
myForm.load(‘1’);

updated one
var myForm = new dhtmlXForm(“my_form”);
myForm.load(“php/data.php?id=1”);

Thanks Stanislav - it’s working OK now, using the original version of the form script.

I now have a different problem, using the Form object .Load() method I get a Javascript error:

Uncaught TypeError: Cannot read property ‘tagName’ of undefined

at Line 1164 of dhtmlxform.js.

Line 1164 reads:

switch(elem[‘object’].tagName){

I am using the dhtmlxform.js version dated 15/03/2010, and the dhtmlxcommon.js file has the same date;

My HTML calls the Form object like this:

myForm = new dhtmlXForm(“data_form”,“mysql_form_connector.php”);

and I am using a function to load the form like this:

function displayForm(id) {
//Uses DHTMLX Form Object to display editable form for specified row of table
//Database Name, Table/SQL, ID and Field List have been identified using SetSessionVariable
myForm.load(id);
}

My PHP file (ysql_form_connector.php) uses this code to fetch the data:

[b]<?php
//
require_once(’…/php/form_connector.php’);
require(’…/php/misc.php’);
//
session_start();
$db_name = getSessionVariable(‘db_name’);
$user_object = getSessionVariable(‘user_object’);
$user_object_id_name = getSessionVariable(‘user_object_id_name’);
$user_object_type = getSessionVariable(‘user_object_type’);
$user_object_sql = getSessionVariable(‘user_object_sql’);
$user_object_field_list = getSessionVariable(‘user_object_field_list’);
//
$dbuser = get_config(‘dbuser’,’’);
$dbpwd = get_config(‘dbpwd’,’’);
$res = mysql_connect(‘localhost’,$dbuser,$dbpwd);
mysql_select_db($db_name,$res);
//
$form = new FormConnector($res);

$form->enable_log(“log.txt”);

//
if($user_object_type == ‘table’) {
$form->render_table($user_object,$user_object_id_name,$user_object_field_list);
} else {
$form->render_sql($user_object_sql,$user_object_id_name,$user_object_field_list);
}
?>[/b]

The meta-data is stored as Session variables, and the Db config are retrieved using the get_config() function.

When I call mysql_form_connector.php in the browser, it generates well-formed XML, and writes to the log:

====================================
Log started, 20/07/2010 11:07:26

SELECT * FROM _menuitem WHERE fk_menu_id=1 AND fk_lang_id=1 AND id = ‘5’ ORDER BY sequence ASC
Done in 0.0086870193481445s

I must be doing something wrong somewhere, but I cannot see it!

Thanks for helping,

Richard