Sql problem

jonathandlynch at gmail.com jonathandlynch at gmail.com
Wed May 24 02:55:39 CEST 2017


One quick note about base64encode:

LC adds linefeeds. After you base64encode, you may need to replace linefeed with empty in the variable.

Sent from my iPhone

> On May 23, 2017, at 8:10 PM, William Prothero via use-livecode <use-livecode at lists.runrev.com> wrote:
> 
> Andre,
> This is good advice. I did it this way as a shortcut for an app I’ve built for myself only. You are right that it makes debugging harder because I can’t use other management applications to examine the contents. 
> 
> For many years now I’ve used php cgi’s to connect to the remote mysql db and it works well. I just haven’t spent the time to set up JSON. 
> 
> But it looks like I could dispense with the php and directly access the mySQL db from my mobile app, without a cgi?
> 
> Best,
> Bill
> 
>> On May 23, 2017, at 3:30 PM, Andre Garzia via use-livecode <use-livecode at lists.runrev.com> wrote:
>> 
>> William,
>> 
>> If I may add a bit of personal opinion here... so, I have been using and
>> storing LC stuff in databases for a long time. Not only I have been storing
>> arrays in database but I had them flying over TCP sockets and being
>> decoded/encoded as needed. For a long time I used the same approach as you,
>> which is to arrayEncode + base64 the array.
>> 
>> I don't do that any longer. That combination is very hard to debug. I would
>> advise you simply to use JSON and store it as JSON on the db. Instead of
>> encoding the array twice, you do it only once with jsonexport() and then
>> when importing, you do it only once with jsonimport()
>> 
>> Not only that reduces complexity but it also makes it a lot easier to
>> debug. As a bonus, your data can be consumed by other applications which
>> are not based on LC which may open a whole ecosystem of plugins and
>> interoperation to your product.
>> 
>> Cheers
>> andre
>> 
>> 
>> On Sun, May 21, 2017 at 9:45 PM, William Prothero via use-livecode <
>> use-livecode at lists.runrev.com> wrote:
>> 
>>> Never mind. I got it working. I’m not exactly sure about the problem
>>> because the method I used should have been quite general. However, what
>>> made it work is that I had the contents of a list field in the array I was
>>> storing and that somehow caused an error when I tried to decode the array.
>>> I deleted that array key, because there was no reason I needed to have it
>>> in the db anyway, and it worked.
>>> 
>>> I’ll look into why and report back if I find anything interesting.
>>> Best,
>>> Bill
>>> 
>>>> On May 21, 2017, at 5:23 PM, William Prothero via use-livecode <
>>> use-livecode at lists.runrev.com> wrote:
>>>> 
>>>> Whoops, I lied.
>>>> The data is stored incorrectly in the simulator too.
>>>> Hmm….
>>>> The IDE stores it correctly. There is something in the encoding that I’m
>>> missing.
>>>> Bill
>>>> 
>>>>> On May 21, 2017, at 5:03 PM, William Prothero via use-livecode <
>>> use-livecode at lists.runrev.com> wrote:
>>>>> 
>>>>> Folks:
>>>>> I have an app that stores data to a mysql database on my server. It
>>> works fine in the IDE and in the iPhone simulator. However, when I load the
>>> app onto the iPhone, the saved data is corrupted.
>>>>> 
>>>>> I am saving an array. The array is saved in a big string that has been
>>> base64 encoded.
>>>>> 
>>>>> When saving, I do:
>>>>> 
>>>>> put arrayEncode(tArray) into tData
>>>>> 
>>>>> put base64encode(tData) into xData
>>>>> 
>>>>> put urlEncode(xData) into xData
>>>>> 
>>>>> xData is sent to the db
>>>>> 
>>>>> When I read back the data, I do the inverse:
>>>>> 
>>>>> urlDecode
>>>>> base64Decode
>>>>> arrayDecode
>>>>> 
>>>>> The base64 data on the db is different when I store it from the iPhone.
>>> I can see this with Navicat, which I use for db management. So, the problem
>>> is in the storing of the data.
>>>>> 
>>>>> What the heck? I am just using a post command to a php script that
>>> writes to the db.
>>>>> 
>>>>> Why would the iPhone data that is sent be different from that sent in
>>> the simulator?
>>>>> 
>>>>> Mac OSX 10.12.4, Livecode 8.1.4 (rc2) and XCode 8.3.
>>>>> 
>>>>> Any suggestions would be welcome.
>>>>> Thanks,
>>>>> Bill P.
>>>>> 
>>>>> William A. Prothero
>>>>> http://earthlearningsolution.org/
>>>>> 
>>>>> _______________________________________________
>>>>> use-livecode mailing list
>>>>> use-livecode at lists.runrev.com
>>>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>>> 
>>>> 
>>>> _______________________________________________
>>>> use-livecode mailing list
>>>> use-livecode at lists.runrev.com
>>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>> 
>>> 
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>> 
>> 
>> 
>> 
>> -- 
>> http://www.andregarzia.com -- All We Do Is Code.
>> http://fon.nu -- minimalist url shortening service.
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> 
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode



More information about the use-livecode mailing list