Share tinydb via Whatsapp

you might want to show us your Do it result of your query
are you able to run any other query like SELECT * FROM sharelist successfully?
are you using any extension?

Taifun

yes clicking on readsql button i can see data that i added via phpmyadmin on my database!

while on writesql button

i am using your script php

and listview and colintreelistview

well, it does not really help so see only a very tiny part of the Do it result, does it?
Unbenannt

what about using your mouse to get that Do it result window larger, copy the result to your clipboard and paste it here into the community, so we can see and verify, if the query is syntactically correct?

the runtime error most probably is coming from the extensions...
my guess is, you are calling them in the Web.GotText event...
as test display your response content in a label and deactivate all other blocks in that event to find out, if you still get the runtime error...
also let me suggest to reconnect the companion app...

Taifun

1 Like

Do It Result: INSERT INTO sharelist (prodotto, img, prezzo, listid) VALUES (https://d2f5fuie6vdmie.cloudfront.net/asset/ita/2020/33/354d6cca34c1605d5ebc74c8aa5998b2670924fa.webp Negroni Pancetta Affumicata in Cubetti 2 x 100 g 3.69 €)(https://d2f5fuie6vdmie.cloudfront.net/asset/ita/2022/3/63b1ca27f9aeb20acc010a387be5d8acb63a67ef.webp Conad Piacersi Mortadella di Pollo 1.99 €)(https://d2f5fuie6vdmie.cloudfront.net/asset/ita/2020/33/c13aa87914f13f5ceedf157f8c72e265482630f3.webp Garofalo Penne Ziti Rigate No. 70 Pasta di Gragnano Igp 1.19 €)1);

Do It Result: INSERT INTO sharelist (prodotto, img, prezzo, listid) VALUES ('(https://d2f5fuie6vdmie.cloudfront.net/asset/ita/2022/3/63b1ca27f9aeb20acc010a387be5d8acb63a67ef.webp Conad Piacersi Mortadella di Pollo 1.99 €)', '(https://d2f5fuie6vdmie.cloudfront.net/asset/ita/2020/32/1ba8d56e7bad660b0e7118c12aba22e7076d6b7d.webp Salzburgmilch Panna Acida 15% Grassi 1.15 €)', '(https://d2f5fuie6vdmie.cloudfront.net/asset/ita/2020/33/354d6cca34c1605d5ebc74c8aa5998b2670924fa.webp Negroni Pancetta Affumicata in Cubetti 2 x 100 g 3.69 €)', '1');

i tryed to add/remove ' and , but insert is always wrong

How do you want the shopping list to be displayed ?

As a text string ?

If yes, tell the format of the text string.

Eg.

Item1Name, Item2Name, Item3Name

Or

Item1Name : Item1Details
Item2Name : Item2Details
Item3Name : Item3Details

i have no problem in display in listview the data that i retrieve from my mysql database

what i want to achieve.. is to store the list of Screen3 that is saved in tinydb into mysql table that has this structure:

1 Like

Is your main problem  Share TinyDB via Whatsapp  (Topic name) solved ?

i want to Share it via mysql database...

i store the list in mysql database and share the listid via whatsapp

so other user can retrieve the list clicking on a button that does the query:

select * from sharelist where listid = 'VALUESHAREDONWHATSAPP'

and put result in listview

1 Like

while
doing

INSERT INTO sharelist VALUES ('69467579','a', '1.75 €', 'b', '5' , '6', '7' );

i can write data on mysql database!

So the problem is in the join to build the query

i tryed also to reproduce the same insert..


to see what happens on label3

Shoplist.aia (145.3 KB)

1 Like

see the correct syntax here MySQL Insert Multiple Rows By Practical Examples

there are no commas between the items of one row, there is no comma between each row and what exactly is the last ,'1'?

Taifun

aia
Shoplist (1).aia (145.4 KB)

it's only a test number... Will be the listid to share to other users...

If i use only This block i can write data on my database!

INSERT INTO sharelist (prodotto, prezzo, img, listid) VALUES
('product1','prize1','img1','7'),
('product2','prize2','img2','7'),
('product3','prize3','img3','7');

My problem is how to pass the values from the list of tinydb to the insert query!

if i remove ' or , in the query i have the invoke virtual method error!

you know now how a correct sql query must look like
and you know how to use Do it to debug your blocks...
now you have to use some logic to build the correct sql query step by step...

for example you could use a for each item in list loop to loop through the items of each sublist to add the quotes around each item and the comma between each item
and you could use another for each item in list loop to loop through the sublists to add the brackets around each sublist and the comma between each sublist...

you also can use procedures ... for example a procedure which returns a quotified item
input:: product1
output: 'product1'

Taifun


the result in the label to "test"

still so far.. but closer!

Shoplist (2).aia (148.1 KB)

I tryed on phpmyadmin to send also this query and it's still ok!

INSERT INTO sharelist( prodotto, prezzo, img, listid) VALUES ('a','b', 'c','d');
INSERT INTO sharelist( prodotto, prezzo, img, listid) VALUES ('a1','a1', 'a1','a1');
INSERT INTO sharelist( prodotto, prezzo, img, listid) VALUES ('a2','a2', 'a2','a2');

i tryed to reproduce in appinventor:

but fails!!

Mysqlquery.aia (146.1 KB)

The problem can be te ( at start and ) at the end that i cannot added?

if i send single query like
INSERT INTO sharelist( prodotto, prezzo, img, listid) VALUES ('a','b', 'c','d');

all is fine :frowning: AFFECTED ROW 1

i tryed also this:


maybe here the problem is that the last is a , and not a ; ????

I am becoming crazy

you have to strictly follow the correct syntax
everything else will fail...

Also it looks like you always plan to insert 3 rows... why not providing a more flexible solution to insert n rows?

Taifun

'

i use n rows i count lines of rows of tinydb

here the syntax is correct except the last character that is a , and not a ; but i have no idea how to change it!

maybe this:
image

this does the job! but i think is a very d1rty solution!

1 Like