Error Description: Incorrect XML

hi,

I’trying to build a running example of datagrid e DataConnector with PHP. There’s no way to run the example but i don’ t understand why. I follow exactly the available examples but without positive results.

This is the code

Index.html

Deve FUNZIONARE
    <link rel='STYLESHEET' type='text/css' href='dhtmlxGrid/codebase/dhtmlxgrid.css'>
	<link rel="stylesheet" type="text/css" href="dhtmlxGrid/codebase/skins/dhtmlxgrid_dhx_skyblue.css">

<script src='dhtmlxGrid/codebase/dhtmlxcommon.js'></script>
<script src='dhtmlxGrid/codebase/dhtmlxgrid.js'></script>  
<script src='dhtmlxDataProcessor/codebase/dhtmlxdataprocessor.js'></script>        
    
<script src='dhtmlxGrid/codebase/dhtmlxgridcell.js'></script>  


connector_Access.php

<?php require("dhtmlxConnector/codebase/grid_connector.php"); require("dhtmlxConnector/codebase/db_pdo.php"); $res = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb)};Dbq=\db_dati.mdb"); $grid = new GridConnector($res, "PDO"); $grid->enable_log("c:\log.txt"); $grid->render_table("utenti_bak"); ?>

What’s wrong ? i receive only an error “Incorrect XML” and the grid remains empty.

Many Thanks in advance.

a) please change render_table command as

$grid->render_table(“utenti_bak”, “id”, “fieldA,fieldB”);

where id, fieldA, fieldB - names of fields which you want to use in grid

b) please be sure that you have not any whitespace in php file before <?php tag

c) if issue still occurs - try to load the data url directly in browser - it will show some extra info about the error.

many thanks again Stanislav.

i followed your suggestions.

  1. There’s no spaces before <?php tag

  2. i changed render_table in
    $grid->render_table(“utenti_bak”, “n_prod_id”,"s_prod_name,f_prod_name,f_prod_price,n_prod_qty,s_prod_total ");
    that are the fields of DB.

  3. i tried to load data in the broweser launching “connector_Access.php” and i received this message
    Fatal error Class ‘PDO’ non found in connector_Access.php on line 4

I read in another your post that it’s necessary to control the precence in PHP.INI of two extensions
extension=php_pdo
extension=php_pdo_odbc

The two extension are not in PHP.INI so i tried to add them but after that the web server expects to find two dll in usr/local/php giving errors on start.
In the php.ini i found also this comment “Note that ODBC support is built in, so no dll si needed for it”

Any other suggestion ?

Thanks again (sorry for my english).

Fatal error Class 'PDO' non found in connector_Access.php on line 4

You need to enable PDO support in the php, unfortunately there is no common solution here, as it vary a lot for different OSes.

Hi Stanislav,

Be patient with me, i’me here again but with a partial success.

i succeded to enable PDO support, downloading the two necessary dll and simply copying them, without any installation, in \usr\local\extension in the web server.
Now the grid is populated with my data as i expected, but this was only the first step. Now i’d like to be able to update/insert/delete rows in my grid and, of course, in the DB.

I tried to adapt another example “update_names.php” and this is now my code:

index.html

Deve FUNZIONARE
    <link rel='STYLESHEET' type='text/css' href='dhtmlxGrid/codebase/dhtmlxgrid.css'>
	<link rel="stylesheet" type="text/css" href="dhtmlxGrid/codebase/skins/dhtmlxgrid_dhx_skyblue.css">

<script src='dhtmlxGrid/codebase/dhtmlxcommon.js'></script>
<script src='dhtmlxGrid/codebase/dhtmlxgrid.js'></script>  
<script src='dhtmlxDataProcessor/codebase/dhtmlxdataprocessor.js'></script>        
<script src='dhtmlxDataConnector/codebase/connector.js'></script>  
<script src='dhtmlxGrid/codebase/dhtmlxgridcell.js'></script>  
<p><a href="javascript:void(0)" onclick="mygrid.addRow((new Date()).valueOf(),[0,'','','',false,'na',false,''],mygrid.getRowIndex(mygrid.getSelectedId()))">Add row</a></p>
<p><a href="javascript:void(0)" onclick="mygrid.deleteSelectedItem()">Remove Selected Row</a></p>

connector_Access.php

<?php require("dhtmlxConnector/codebase/grid_connector.php"); require("dhtmlxConnector/codebase/db_pdo.php"); $res = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\db\db_dati.mdb"); $grid = new GridConnector($res,"PDO"); $grid->render_table("utenti_bak","n_prod_id","n_prod_id,s_prod_name,f_prod_price,n_prod_qty,s_prod_total"); ?>

update_names.php

<?php //code below is simplified - in real app you will want to have some kins session based autorization and input value checking error_reporting(E_ALL ^ E_NOTICE); //include db connection settings require("dhtmlxConnector/codebase/grid_connector.php"); require("dhtmlxConnector/codebase/db_pdo.php"); $res = new PDO("odbc:Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\db\db_dati.mdb"); $grid = new GridConnector($res,"PDO"); function add_row(){ global $newId; $sql = "INSERT INTO utenti_bak(s_prod_name,f_prod_price,n_prod_qty,s_prod_total) VALUES ('".addslahses($_GET["s_prod_name"])."', '".$_GET["f_prod_price"]."', '".$_GET["n_prod_qty"]."', '".$_GET["s_prod_total"]."')"; $res = mysql_query($sql); //set value to use in response $newId = mysql_insert_id(); return "insert"; } function update_row(){ $sql = "UPDATE utenti_bak s_prod_name='".addslashes($_GET["s_prod_name"].)"', f_prod_price= '".$_GET["f_prod_price"]."', n_prod_qty= '".$_GET["n_prod_qty"]."', s_prod_total= '".$_GET["s_prod_total"]."' WHERE n_prod_id=".$_GET["n_prod_id"]; $res = mysql_query($sql); return "update"; } function delete_row(){ $d_sql = "DELETE FROM utenti_bak WHERE n_prod_id=".$_GET["n_prod_id"]; $resDel = mysql_query($d_sql); return "delete"; } //include XML Header (as response will be in xml format) header("Content-type: text/xml"); //encoding may differ in your case echo('<?xml version="1.0" encoding="iso-8859-1"?>');

$mode = $_GET["!nativeeditor_status"]; //get request mode
$rowId = $_GET[“n_prod_id”]; //id or row which was updated
$newId = $_GET[“n_prod_id”]; //will be used for insert operation

switch($mode){
case “inserted”:
//row adding request
$action = add_row();
break;
case “deleted”:
//row deleting request
$action = delete_row();
break;
default:
//row updating request
$action = update_row();
break;
}

//output update results
echo “”;
echo “”;
echo “”;

?>


In this last script, that’s the problem, is enough to change the fields name or is necessary to change also the functions “mysql_query” and “mysql_insert_id” with other specific functions that i don’t know and i didn’t find in the examples ?

Many many thanks

a) technically, all you need is

var myDP = new dataProcessor(“connector_Access.php”);
myDP.init(mygrid);

The same file which you are using for data loading can be used for data saving, without any extra coding.

b) if you want to use a custom code for data saving

  • on client side

var myDP = new dataProcessor("update_names.php"); myDP.setUpdateMode("GET", false); myDP.enableDatanames(true); myDP.init(mygrid);

  • on server side

replace mysql_query with PDO related API, there is no direct one-to-one mapping, you will need to have something like

$pdo = new PDO($dsn,$user,$pass,$options); $pdo->query(... sql code ...);

i just understood that it’s enough using the same file “connector_Access” also for update, the problem is that the grid seems to run updating, inserting and deleting rows but no update arrives to Database.

This is why i tried to use “update_names.php”. I don’t know if the syntax of all senteces is correct, anyway nothing happens the same. No update on DB !

What else can I do ? Help.
Why MSACCESS is only partially supported and nothing about ADOConnection like in ASP ?
In Companies environments Access is very used for small projects !

Thanks for your time and patience.

Try to enable logging and check log for error details

docs.dhtmlx.com/doku.php?id=dhtm … tor:errors

Why MSACCESS is only partially supported and nothing about ADOConnection like in ASP ?
There is no native Access driver for PHP, and in case of PDO, access DB driver do not support some common SQL idioms. ( Need to say, that both java and .net connectors do support Access, because there are good native drivers for those platforms )

Hi Stanislav,

I tried to activate logging but the only message that i received is this one in all cases (using only connector_Access.php also for update/insert/delete or using update_names.php

====================================
Log started, 05/10/2012 05:10:11

SELECT n_prod_id,n_prod_id,s_prod_name,f_prod_price,n_prod_qty,s_prod_total FROM utenti_bak

Done in 0.0053129196166992s

The only strange Error message that i found come from script debugging of Internet Explorer regards “myDP.enableDatanames(true);” that is not recognized as method of the object !?!

I really don’t know what else to try ! could it depend on ODBC connection ? in the sense that, maybe, it is necessary to open the connection with some “write” permission ?. it seems strange !
I hope in you !!!

Concernig your answer about ADO, i found trough Internet code examples to use ADO.Connection in PHP (see the example below) and using Windows, nothing else (libraries or other) seems to be necessary to use it.
It could be interesting including the support in the suite.

ShotDev.Com Tutorial <?php $strConn = new COM("ADODB.Connection") or die("Cannot start ADO"); $strConn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("db/mydatabase.mdb")); $strSQL = "SELECT * FROM customer "; $objRec = new COM("ADODB.Recordset"); $objRec->Open($strSQL, $strConn, 1,3);

if($objRec->EOF)
{
echo “Not found Record.”;
}
else
{

$PageLen = 2;
$PageNo = $_GET[“Page”];
if(!$PageNo)
{
$PageNo = 1;
}
$TotalRecord = $objRec->RecordCount();
$objRec->PageSize = $PageLen;
$TotalPage = $objRec->PageCount();
$objRec->AbsolutePage = $PageNo;

?>

<? While (!($objRec->EOF) and $No < $PageLen) { ?> <? $No = $No + 1; $objRec->MoveNext(); } ?>
CustomerID
Name
Email
CountryCode
Budget
Used
<?=$objRec->Fields["CustomerID"]->Value;?>
<?=$objRec->Fields["Name"]->Value;?> <?=$objRec->Fields["Email"]->Value;?>
<?=$objRec->Fields["CountryCode"]->Value;?>
<?=$objRec->Fields["Budget"]->Value;?> <?=$objRec->Fields["Used"]->Value;?>
<? }

$objRec->Close();
$strConn->Close();
$strConn = null;
?>

Total : <?=$TotalRecord?> Page <?=$PageNo?> All Page <?=$TotalPage?>

<? if($PageNo > 1){ ?>

<< First
< Back

<? }?> <? if($PageNo < $TotalPage) { ?>

Next >
Last >>

<?}?>
Go to <? for($intID=1;$intID<=$TotalPage;$intID++){?> <? if($intID == $PageNo){?> <?=$intID?> <?}else{?> <?=$intID?> <?}?> <?}?>

If you want to use connector for data saving, you must include connector.js ( be sure that it is included after dataprocessor.js ) and you must not use enableDatanames or setUpdateMode as they are not supported by connector.

Hi Stanislav, I’m here again.

You are right i didn’t include correctly “connector.js” but solved a problem another one appears ! it looks like a puzzle !

Without connector.js the grid was regularly populated but when i made updates/insert or delete nothing was transfer to the database.
Now, including connector.js when i start the app only the empty grid is shown and i received a crash message from Apache as you can see on the Screenshots in the attachment.
The first time the message was different and was refferred to the famous PHP_PDO_ODBC.DLL that wasn’t correctly loaded, but i solved the error changing the path of extension_dir in PHP.INI from the relative to the absolute path.
Now the reference is to “Kernel32.dll” that is a System library, surely correctly loaded in the system !

I don’t know what else i could do. As always you are my last hope.

Thank you.



There were no similar reports, so it hard to say, what is happens
It seem that apache crashed during php script execution , you can check the logs in apache/log directore for more details. ( I suspect that it was caused by some problem with access database - invalid rights or invalid path, or something similar )

Hi Stanislav,

I abandoned the idea to use MSAccess as Database and I’m positively trying Mysql, but the problem are always ready to throw a spanner in the works.

I’m trying to use render_complex_sql as i have to filter the records with the sentence “WHERE”, but i have some problems:

  1. the first is rather strange. The application give a lot of error caused to the definition of some fields in the grid that i want to populate. This fields are “coro” or “co” type. If i changed theese definitions in “ed”, for instance, the application runs correctly, but i would need to use combo with this fields

  2. Even if i use a single table with the “WHERE” clause based on a field of the same table, the system is not able to complete the update/insert on DB.
    In the Documentation there is this sentence:
    “In case your SQL query was against a single table, it is quite probable that insert/update/delete operations do not require any additional code. dhtmlxConnector will parse your SQL and generate insert/update/delete statements based on used table and fields names.”

I’d have also another question:

How can I divide the configuration xml (file .xml) of the grid and the load of data from DB. If i try to load configuration with LoadXML and then i use LoadXml another time to load data from DB, the configuration is lost.

Can you help me ! thanks

I’m trying to use render_complex_sql as i have to filter the records with the sentence “WHERE”
In most cases common render_sql will work fine with WHERE ( while it doesn’t have sub-selects )

If you are using co and coro columns in grid, connector will try fetch list of options for them, for that it will try to generate “select distinct” sql query for the related field ( which is probably fail in case of complex sql ). You can define the correct sql or use predefined set of values by using set_options API

docs.dhtmlx.com/doku.php?id=dhtm … _with_data

(2)
Be sure to use render_sql, not render_complex_sql

render_sql - autogenerates CRUD operations
render_complex_sql - do no attempt to parse incoming sql code, execute it as is, and as result can’t generate CRUD operations.

and then i use LoadXml another time to load data from DB, the configuration is lost
a) you can define configuration as part of connector
docs.dhtmlx.com/doku.php?id=dhtm … erver-side

b) if you are using code like next - it must work correctly with separate xml configuration

grid.load("config.xml", function(){ //grid's config
     grid.load("data.php"); //data from connector
})

Hi Stanislav,

I’m here again, i don’t want abandon the fight !

I followed your suggestions and i used render_sql and the set_option on server side to load data in the combo. Now i have theese problems.

  1. The grid loads the query and also the combos, but debugging the script i receive this error:

SCRIPT438: The object doesn’t support the property or the method ‘fillColumnCombos’
dhtmlx.js, Row 658 Carachter 380

What’s wrong ?

  1. Even if i use render_sql the updates/inserts don’t arrive to Database. Why ?

Be patient and help me again ! Thanks

Please send a full js|html code of test page where above problem occurs to support@dhtmlx.com ( just a client side code, without server side ) Be sure to mention the forum topic in the email’s title.

The object doesn’t support the property or the method ‘fillColumnCombos’
This is related to loading options collections for combos in grid, but I’m unsure why it can occur

Even if i use render_sql the updates/inserts don’t arrive to Database.
They do not appear in server side logs? Check that connector.js is included on the page ( and is included after dataprocessor.js ) - it possible that due to incorrect dataprocessor configuration, update commands is not recognized on server side. Normally you just need to create a dataprocessor object and call dp.init, there is no need for any extra dataprocessor configuration.

Hi Stanilav,

Well, i started from the code of your Tutorial Contacts and i’m trying to build a grid with some fields using edn and coro fields with one ro field containing math formulas. The problem are two

  • the first, as i said in my previous message, is that using render_sql to populate the grid the update/insert haven’t effects on the DB. You talked about including connector.js and dataconnector.js but in your Contact Tutorial there is only an include: “dhtmlx.js” and you wrote in comments that “contains all necessary dhtmlx library javascript code”.

  • the second problem is that in the column wich contains formulas, something strange has happening.
    in c10 there is this formula
    ro[=if (c2==10){10}else{0}] and runs correctly because i do the test on a numeric Field

instead with
ro[=if (c7==‘SI’){10}else{0}] doesn’t run because, i suppose, i do the test on a text Field

I hope it wouldn’t be a limit of math formulas in your framework, that’s applied only to numerical fields.

Thanks for your patience.

but in your Contact Tutorial there is only an include: “dhtmlx.js” and you wrote in comments that “contains all necessary dhtmlx library javascript code”.

Yep, if you are using latest build - it must be include all necessary components, but just to be on safe way, try to include both dhtmlx.js and connector.js
docs.dhtmlx.com/doku.php?id=tuto … today:init

I hope it wouldn’t be a limit of math formulas in your framework
Actually it is hardcoded, to allow string values, locate and change in dhtmlxgrid_math.js all occurences of

return “(parseFloat(…some…,10)”

to

return “…some…”

Hi again Stanislav,

I’m rather discouraged. At each step there is a new problem.

I tried to include connector.js in the way that you indicated. Nothing runs at all returning the error “Stack overflow at line 43”. I’m not sure but it seems to be something duplicated.

For the other problem, i didn’t include dhtmlxgrid_math.js but with numbers the calculation run the same, so i think it wouldn’t be necessary to include it. Looking at dhtmlx.js i found some occurencies of parseInt(…some…,10) instead of parseFloat and never near to “return”

have I to change theese sentences in this file ?

Thanks a lot.

dhtmlxgrid_math.js is a part of dhtmlx.js
To not mess with compressed file - just add content of attached path to the end of dhtmlx.js or just as one more js file on the page.
patch.zip (785 Bytes)