PDA

View Full Version : PHP + 'no element found' error message [CLOSED]



bello
23 Mar 2010, 1:07 PM
Hi. I am trying to run some PHP code to read a database - and I can't. I always get the error message 'no element found' and the error console always points to the last line of the php file : the '?>' characters. I get the message whether the webserver is running or not, which implies some basic parsing error, but it's a mystery to me.

Here is the JS code to read the database :


var supplier_fields =
[
{name: 'db_sup_id'},
{name: 'db_sup_name'}
];

var supplier_store = new Ext.data.JsonStore
({
url: 'suppliers.php',
root: 'suppliers',
autoLoad: false,
remoteSort: false,
idProperty: 'db_sup_id',
successProperty: 'success',
fields: supplier_fields
});

supplier_store.load
({
callback: function(records, options, success)
{
if (success){Ext.Msg.alert('SUCCESS : ' + records.length);}
else{Ext.Msg.alert('FAILURE : ' + records.length);}
}
});Here is the current 'suppliers.php' file :


<?php
header('Content-Type: text/plain');
echo '{"success":true, "suppliers":[{"db_sup_id":1,"db_sup_name":"Supermarket"}]}';
?>I always get the 'FAILURE' alert, with zero records, and the error message, regardless of what the content of the PHP file actually is.

I have tried various versions of EXTJS and Firefox and IE running with xampplite.

Has anybody any ideas ? Thanks.