Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Another Missing Data in the Grid Problem
23/07/2011
03:50
Avatar
GeorgeIoak
Member
Members
Forum Posts: 4
Member Since:
23/07/2011
sp_UserOfflineSmall Offline

I've been searching the forum trying to find some clues but I just can't seem to find the answer so hopefully someone will spot the problem. Here's my HTML code which is jusy slightly modified from the example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DT.....038;hellip;..">
<html xmlns="http://www.w3.org/1999/xhtml&quot; xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My First Grid</title>
 
<link rel="stylesheet" type="text/css" media="screen" href="css/cupertino/jquery-ui-1.8.14.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
 
 <style>
html, body {
    margin: 0;
    padding: 0;
    font-size: 75%;
}
</style>
 
<script src="js/jquery-1.5.2.min.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
 
<script type="text/javascript">
jQuery(document).ready(function(){
    jQuery("#list").jqGrid({
    url:'dbconnect.php?q=1',
    datatype: 'xml',
    mtype: 'GET',
    colNames:['ID', 'Title', 'Org. Name', 'First Name', 'Last Name', 'Address', 'City', 'State', 'Zipcode', 'Home Phone', 'Work Phone', 'Email'],
    colModel :[
      {name:'id', index:'id', width:15},
      {name:'title', index:'title', width:55},
      {name:'orgname', index:'orgname', width:100},
      {name:'fname', index:'fname', width:80, align:'right'},
      {name:'lname', index:'lname', width:100, align:'right'},
      {name:'address', index:'address', width:120, align:'right'},
      {name:'city', index:'city', width:80,},
      {name:'state', index:'state', width:40,},
      {name:'zipcode', index:'zipcode', width:50,},
      {name:'homephone', index:'homephone', width:80,},
      {name:'workphone', index:'workphone', width:80,},
      {name:'email', index:'email', width:100,}
    ],
    pager: '#pager',
    rowNum:10,
    rowList:[10,20,30],
    sortname: 'lname',
    sortorder: 'desc',
    viewrecords: true,
    gridview: true,
    caption: 'My first grid'
  });
});
</script>
 
</head>
<body>
<table id="list"><tr><td/></tr></table>
<div id="pager"></div>
</body>
</html>

I'm using FireBug to decode the problems and it appears that the XML is getting data and in the proper format however I'm getting this error in the reponse before the actual XML code:

<b>Warning</b>:  Cannot modify header information – headers already sent by (output started at /home/mydomainname/public_html/db/jqGrid/dbconnect.php:51) in <b>/home/mydomainname/public_html/db/jqGrid/dbconnect.php</b> on line <b>56</b><br />

 

the end of my dbconnect.php file is:

 

 

$SQL = "SELECT ". $dbcolumns. "FROM ". $dbtable. " ORDER BY ".$sidx." ".$sord." LIMIT ".$start." , ".$limit;
        echo $SQL;
        $result = mysql_query( $SQL ) or die("Couldn't execute query.".mysql_error());
        
        if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) {
        header("Content-type: application/xhtml+xml;charset=utf-8"); } else {
        header("Content-type: text/xml;charset=utf-8");
        }
        $et = ">";
        $s = "<?xml version='1.0' encoding='utf-8'?>";
        $s .=  "<rows>";
        $s .= "<page>".$page."</page>";
        $s .= "<total>".$total_pages."</total>";
        $s .= "<records>".$count."</records>";
        while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
            $s .= "<row id='". $row['id']."'>";            
            $s .= "<cell>". $row['title']."</cell>";
            $s .= "<cell>". $row['orgname']."</cell>";
            $s .= "<cell>". $row['fname']."</cell>";
            $s .= "<cell>". $row['lname']."</cell>";
            $s .= "<cell>". $row['address']."</cell>";
            $s .= "<cell>". $row['city']."</cell>";
            $s .= "<cell>". $row['state']."</cell>";
            $s .= "<cell>". $row['zipcode']."</cell>";
            $s .= "<cell>". $row['homephone']."</cell>";
            $s .= "<cell>". $row['workphone']."</cell>";
            $s .= "<cell><![CDATA[". $row['email']."]]></cell>";
            $s .= "</row>";
        }
        $s .= "</rows>";
        
        echo $s;

?>

and finally the XML response (note that I changed some data to protect some information)

 

 

SELECT id, title, orgname, fname, lname, address, city, state, zipcode, homephone, workphone, email FROM MailingList ORDER BY lname desc LIMIT 0 , 10<br />
<b>Warning</b>:  Cannot modify header information – headers already sent by (output started at /home/iotllcc1/public_html/db/jqGrid/dbconnect.php:51) in <b>/home/iotllcc1/public_html/db/jqGrid/dbconnect.php</b> on line <b>56</b><br />
<?xml version='1.0' encoding='utf-8'?><rows><page>1</page><total>1180</total><records>11793</records><row id='1923'><cell></cell><cell></cell><cell>Deborah xxx</cell><cell>xxx</cell><cell>xxx West "K" Street</cell><cell>Benicia</cell><cell>CA</cell><cell>94510-    </cell><cell>(707) 745-xxxx</cell><cell></cell><cell><![CDATA[]]></cell></row><row id='6763'><cell></cell><cell></cell><cell>A</cell><cell>xxxx</cell><cell>451 xxxx Court</cell><cell>Benicia</cell><cell>CA</cell><cell>94510-    </cell><cell>(707) 745-xxxx</cell><cell></cell><cell><![CDATA[]]></cell></row><row id='11347'><cell></cell><cell></cell><cell>Lisa</cell><cell>xxxx</cell><cell></cell><cell></cell><cell></cell><cell></cell><cell></cell><cell></cell><cell><![CDATA[xxxx.xxxx@yahoo.com]]></cell></row><row id='1024'><cell></cell><cell></cell><cell>Ann</cell><cell>xxxx</cell><cell>451 xxxxCourt</cell><cell>Benicia</cell><cell>CA</cell><cell>94510-    </cell><cell>(707) 745-xxxx</cell><cell></cell><cell><![CDATA[xxxx@earthlink.com]]></cell></row><row id='997'><cell></cell><cell></cell><cell>Betty</cell><cell>xxxx</cell><cell>1595 xxxxSt.</cell><cell>San Francisco</cell><cell>CA</cell><cell></cell><cell>(415) 775-xxxx</cell><cell></cell><cell><![CDATA[]]></cell></row><row id='6948'><cell></cell><cell></cell><cell>Val</cell><cell>xxxx</cell><cell>1201 xxxxxxxxParkway #610</cell><cell>Vallejo</cell><cell>CA</cell><cell>94591-    </cell><cell></cell><cell></cell><cell><![CDATA[]]></cell></row><row id='3789'><cell></cell><cell></cell><cell>Val</cell><cell>xxxx</cell><cell>xxxx Glen Cove Parkway #xxxx</cell><cell>Vallejo</cell><cell>CA</cell><cell>94589-    </cell><cell>(707) 557-xxxx</cell><cell></cell><cell><![CDATA[xxxx@yahoo.com]]></cell></row><row id='7946'><cell></cell><cell></cell><cell></cell><cell>xxxx</cell><cell>xxxxxxxxRoad #27</cell><cell>Benicia</cell><cell>CA</cell><cell>94510-    </cell><cell></cell><cell></cell><cell><![CDATA[]]></cell></row><row id='6462'><cell></cell><cell></cell><cell>Charles</cell><cell>xxxx</cell><cell>xxxxxxxxRoad Apt 27</cell><cell>Benicia</cell><cell>CA</cell><cell>94510-    </cell><cell></cell><cell></cell><cell><![CDATA[]]></cell></row><row id='8813'><cell></cell><cell></cell><cell>C.G.</cell><cell>xxxx</cell><cell>xxxxRoad #27</cell><cell>Benicia</cell><cell>CA</cell><cell>94510-    </cell><cell>(707) 747-xxxx</cell><cell></cell><cell><![CDATA[]]></cell></row></rows>

 

So I see the grid but it isn't populated with any data. Must be just something simple but I can't seem to find out what it is!

23/07/2011
05:04
Avatar
GeorgeIoak
Member
Members
Forum Posts: 4
Member Since:
23/07/2011
sp_UserOfflineSmall Offline

Sorry guys, I found the problem. When I was initially trying to debug the code I had added an echo statement in the dbconnect.php file:

 echo $SQL;

That statement was corrupting the XML output causing both the header error as well as the data not being parsed correctly.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
64 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information