Connect to SQL

For using DHTMLX Gantt in ms access, I try to connect to our SQL database. But I always get the fault “invalid data”.

What am I doing wrong?

Hereby the code:

Planning.html:

How to Start with dhtmlxGantt html, body{ margin:0px; padding:0px; height:100%; overflow:hidden; }
gantt.config.xml_date = "%Y-%m-%d %H:%i"; gantt.init("gantt_here"); gantt.load('data.php');
var dp=new dataProcessor("data.php");   
dp.init(gantt);
</script>

data.php:

<?php include ("./codebase/connector/gantt_connector.php"); $dbtype = "MySQL"; $res=mysql_connect("FS-DRM-01/Snelstart", "sa", "******"); mysql_select_db("Planning"); $gantt = new JSONGanttConnector($res, $dbtype); $gantt->enable_log("log.txt,true"); $gantt->mix("open", 1); $gantt->render_links("dbo.gantt_links", "id", "source,target,type"); $gantt->render_table("dbo.gantt_tasks","id", "start_date,duration,text,progress,sortorder,parent",""); ?>

Can you show the server output from data.php?

Thanks for your reply.

What do you mean with ‘server output’? I don’t get a log file in the folder.

Try to open data.php directly in browser, does it shows data or some error message ?
( if output is empty - probably you need to enable error output in php.ini or check global php error log for details )

i have same error too like that, here my file :
myGantt.html :

How to start with dhtmlxG html, body{ margin:0px; padding:0px; height:100%; overflow:hidden; }
        var tasks = {
        data:[
        {id:1, text:"Project #1",start_date:"01-04-2013", duration:11,
        progress: 0.6, open: true},
        {id:2, text:"Task #1",   start_date:"03-04-2013", duration:5, 
        progress: 1,   open: true, parent:1},
        {id:3, text:"Task #2",   start_date:"02-04-2013", duration:7, 
        progress: 0.5, open: true, parent:1},
        {id:4, text:"Task #2.1", start_date:"03-04-2013", duration:2, 
        progress: 1,   open: true, parent:3},
        {id:5, text:"Task #2.2", start_date:"04-04-2013", duration:3, 
        progress: 0.8, open: true, parent:3},
        {id:6, text:"Task #2.3", start_date:"05-04-2013", duration:4, 
        progress: 0.2, open: true, parent:3}
        ],
        links:[
        {id:1, source:1, target:2, type:"1"},
        {id:2, source:1, target:3, type:"1"},
        {id:3, source:3, target:4, type:"1"},
        {id:4, source:4, target:5, type:"0"},
        {id:5, source:5, target:6, type:"0"}
        ]
        };
        gantt.config.xml_date = "%Y-%m-%d %H:%i";
        gantt.init("gantt_here");
        gantt.load('data.php')
        
        var dp=new dataprocessor('data.php');
        dp.init(gantt)
        gantt.parse (tasks);
        
        
    </script>
</body>

data.php :

<?php include ('codebase/connector/gantt_connector.php'); $res = mysql_connect("localhost","root","m0dule"); mysql_select_db("gantt"); $gantt = new JSONGanttConnector($res); $gantt->render_links("gantt_links","id","source,target,type"); $gantt->render_table( "gantt_tasks", "id", "start_date,duration,text,progress,sortorder,parent"); ?>

in my condition, my server output of data.php have same data like on database,
but its not show in main page of myGantt.html

please, help rush :frowning:

Hi,
please show the server output from data.php

btw, probably you don’t need this line (as well as inline tasks/links) since you loading data from server gantt.parse (tasks);

this my server output, sorry i just attach image :stuck_out_tongue:
im newbie


oh yeah sure, i have delete

gantt.parse (tasks);
<!DOCTYPE html>
<html>
    <head>
        <title>How to start with dhtmlxG</title>
        <script src="codebase/dhtmlxgantt.js"></script>
        <link href="codebase/dhtmlxgantt.css" rel="stylesheet">
        <style type="text/css" media="screen">
        html, body{
        margin:0px;
        padding:0px;
        height:100%;
        overflow:hidden;
        }   
        </style>
    </head>
    <body>
        <div id="gantt_here" style="width: 100%; height: 100%;"></div>
        <script type="text/javascript">
            
            
            var tasks = {
            data:[
            {id:1, text:"Project #1",start_date:"01-04-2013", duration:11,
            progress: 0.6, open: true},
            {id:2, text:"Task #1",   start_date:"03-04-2013", duration:5, 
            progress: 1,   open: true, parent:1},
            {id:3, text:"Task #2",   start_date:"02-04-2013", duration:7, 
            progress: 0.5, open: true, parent:1},
            {id:4, text:"Task #2.1", start_date:"03-04-2013", duration:2, 
            progress: 1,   open: true, parent:3},
            {id:5, text:"Task #2.2", start_date:"04-04-2013", duration:3, 
            progress: 0.8, open: true, parent:3},
            {id:6, text:"Task #2.3", start_date:"05-04-2013", duration:4, 
            progress: 0.2, open: true, parent:3}
            ],
            links:[
            {id:1, source:1, target:2, type:"1"},
            {id:2, source:1, target:3, type:"1"},
            {id:3, source:3, target:4, type:"1"},
            {id:4, source:4, target:5, type:"0"},
            {id:5, source:5, target:6, type:"0"}
            ]
            };
            gantt.config.xml_date = "%Y-%m-%d %H:%i";
            gantt.init("gantt_here");
            gantt.load('data.php')
            
            var dp=new dataprocessor('data.php');
            dp.init(gantt)
            
            
        </script>
    </body>
</html>

but the display is empty, i dont know why :frowning:
please help

sorry i forogt some code in myGantt.html

<!DOCTYPE html>
<html>
    <head>
        <title>How to start with dhtmlxG</title>
        <script src="codebase/dhtmlxgantt.js"></script>
        <link href="codebase/dhtmlxgantt.css" rel="stylesheet">
        <style type="text/css" media="screen">
        html, body{
        margin:0px;
        padding:0px;
        height:100%;
        overflow:hidden;
        }   
        </style>
    </head>
    <body>
        <div id="gantt_here" style="width: 100%; height: 100%;"></div>
        <script type="text/javascript">
            
            
            var tasks = {
            data:[
            {id:1, text:"Project #1",start_date:"01-04-2013", duration:11,
            progress: 0.6, open: true},
            {id:2, text:"Task #1",   start_date:"03-04-2013", duration:5, 
            progress: 1,   open: true, parent:1},
            {id:3, text:"Task #2",   start_date:"02-04-2013", duration:7, 
            progress: 0.5, open: true, parent:1},
            {id:4, text:"Task #2.1", start_date:"03-04-2013", duration:2, 
            progress: 1,   open: true, parent:3},
            {id:5, text:"Task #2.2", start_date:"04-04-2013", duration:3, 
            progress: 0.8, open: true, parent:3},
            {id:6, text:"Task #2.3", start_date:"05-04-2013", duration:4, 
            progress: 0.2, open: true, parent:3}
            ],
            links:[
            {id:1, source:1, target:2, type:"1"},
            {id:2, source:1, target:3, type:"1"},
            {id:3, source:3, target:4, type:"1"},
            {id:4, source:4, target:5, type:"0"},
            {id:5, source:5, target:6, type:"0"}
            ]
            };
            gantt.config.xml_date = "%Y-%m-%d %H:%i";
            gantt.init("gantt_here");
            gantt.load('data.php');
            
            var dp=new dataprocessor('data.php');
            dp.init(gantt);
            
        </script>
    </body>
</html>

before this, i forgot ‘;’
on

gantt.load('data.php')

and

dp.init(gantt)

but nothing have change :stuck_out_tongue:

Hi,
the task from your data.php has id=1 and parent=2 (id of parent task)

The id of the top level items should be equal to root_id config docs.dhtmlx.com/gantt/api__gantt … onfig.html , by default it can be 0 or undefined. If parent task not found - item wont be displayed

In case you have load an inline data items, and one of the items has the same id that one comes from the server, gantt will update old item with the values from the server

i have try that sir, but the display notice “Invalid Data”
this my update of myGantt.html

<!DOCTYPE html>
<html>
    <head>
        <title>How to start with dhtmlxG</title>
        <script src="codebase/dhtmlxgantt.js"></script>
        <link href="codebase/dhtmlxgantt.css" rel="stylesheet">
        <style type="text/css" media="screen">
        html, body{
        margin:0px;
        padding:0px;
        height:100%;
        overflow:hidden;
        }   
        </style>
    </head>
    <body>
        <div id="gantt_here" style="width: 100%; height: 100%;"></div>
        <script type="text/javascript">
            gantt.config.root_id = "root"; 
            
            var tasks = {
            data:[
            {id:1, text:"Project #1",start_date:"01-04-2013", duration:11,
            progress: 0.6, open: true},
            {id:2, text:"Task #1",   start_date:"03-04-2013", duration:5, 
            progress: 1,   open: true, parent:1},
            {id:3, text:"Task #2",   start_date:"02-04-2013", duration:7, 
            progress: 0.5, open: true, parent:1},
            {id:4, text:"Task #2.1", start_date:"03-04-2013", duration:2, 
            progress: 1,   open: true, parent:3},
            {id:5, text:"Task #2.2", start_date:"04-04-2013", duration:3, 
            progress: 0.8, open: true, parent:3},
            {id:6, text:"Task #2.3", start_date:"05-04-2013", duration:4, 
            progress: 0.2, open: true, parent:3}
            ],
            links:[
            {id:1, source:1, target:2, type:"1"},
            {id:2, source:1, target:3, type:"1"},
            {id:3, source:3, target:4, type:"1"},
            {id:4, source:4, target:5, type:"0"},
            {id:5, source:5, target:6, type:"0"}
            ]
            };
            gantt.config.xml_date = "%Y-%m-%d %H:%i";
            gantt.init("gantt_here");
            gantt.load('data.php');
            
            var dp=new dataprocessor('data.php');
            dp.init(gantt);
            
        </script>
    </body>
</html>

i have invalid data coz, i have not launch myGantt.html in my localhost,
but its still blank sir,

Try to replace

gantt.load('data.php');

with

gantt.parse(tasks, "json");

docs.dhtmlx.com/gantt/snippet/bfe92c74

Does gantt shows some data now ? Your original code looks correct, just check that data.php returns valid json data.