Ok. Got round the php4 issue. Any clues on how to do "data from server is saved in serverresponse"?
Thanks On Feb 9, 2:34 pm, meerkat <[email protected]> wrote: > The web server I am working with is still on php4. This means > json_encode($dataarray); is not supported. What strategy would I use > instead? > Thanks, > meerkat > > On Feb 9, 1:03 pm, "Tosca Lahiri" <[email protected]> wrote: > > > Thanks for this advice. > > In the php code is the $dataarray made up of: > > [fieldname, value]? > > > I have found the xml tutorial you suggested...it is very good. That is what > > made me go down the xml route. I can see now however why the json option is > > preferable. > > TML > > > -----Original Message----- > > > From: [email protected] [mailto:[email protected]] > > > On Behalf Of Oblygre > > > Sent: Monday, February 09, 2009 6:41 AM > > > To: Gears Users > > > Subject: [gears-users] Re: MYSQL XML SQLITE > > > > I think its easier to use json istead of xml, this saves a lot of time > > > in javascript, and PHP have built in functions to convert to json. > > > > Example: > > > > In your php script: > > > echo json_encode($dataarray); // $dataarray contains all your db data > > > > In your gearscode: > > > //data from server is saved in serverresponse > > > // > > > try { > > > eval("dataarr="+serverresponse); > > > > } > > > catch (ex) { > > > alert("Error: No valid data found.."); > > > return; > > > } > > > > var dbcount=0; > > > var reply="no reply"; > > > var db ; > > > db= google.gears.factory.create('beta.database'); > > > if (db) { > > > db.open('yourdatabase'); > > > db.execute('begin'); > > > db.execute('drop table if exists yourtable'); > > > db.execute('create table if not exists yourtable' + > > > ' (yourfield1, yourfield2, yourfield3, primary key > > > (yourfield1))'); > > > for (x in dataarr) > > > { > > > db.execute('insert into yourtable values(?,?,?)', > > > [dataarr[x].yourfield1,dataarr[x].yourfield2,dataarr > > > [x].yourfield3]; > > > dbcount++; > > > //if (dbcount%100==0) > > > //wp.sendMessage(dbcount+" record(s) added....", > > > message.sender); > > > } > > > } > > > db.execute('commit'); > > > db.close(); > > > reply=dbcount+" record(s) added from main DB, finished"; > > > > A link to a tutorial using XML: > > >http://www.onlamp.com/pub/a/onlamp/2007/06/28/the-power-of-google-gears- > > > part-1.html > > > > On Feb 8, 2:37 am, TML <[email protected]> wrote: > > > > Just to clarify...I mean programmatically, not a one off with a tool. > > > > When the user goes online on their pda the data is imported into the > > > > locally held sqlite db. > > > > > On Feb 8, 1:34 am, TML <[email protected]> wrote: > > > > > > Hello, > > > > > > I have a MySQL DB on web server. I have php page that extracts the > > > > > data from table and creates an XML file. > > > > > > Now, I need to know how to import that data in the XML file into the > > > > > Gears sqlite DB on PDA? > > > > > > Any suggestions? > > > > > > Thanks, > > > > > TML
