Android Question sql query confusion

tufanv

Expert
Licensed User
Longtime User
Hello,

In my app i use http job download2 to execute sql queries. For insert i use in my php code
B4X:
$q = mysql_query("INSERT INTO tbldoviz (usd, usd1, usd2, eur, eur1, eur2, chf, chf1, chf2,jpy,jpy1,jpy2,sar,sar1,sar2,gbp,gbp1,gbp2) VALUES ('$d1', '$d2', '$d3', '$d4', '$d5', '$d6', '$d7', '$d8', '$d9', '$d10', '$d11', '$d12', '$d13', '$d14', '$d15', '$d16', '$d17', '$d18')");

works good.
But for update i cant update multiple coloumns . ( i want to update some of the coloumns )
B4X:
    $q = mysql_query("UPDATE tbldoviz set usd='$d1', usd1='$d2', usd2='$d3', eur='$d4', eur1='$d5', eur2='$d6', chf='$d7', chf1='$d8', chf2='$d9', jpy='$d10');

this gives me 500 internal error.
I am not too much familiar with php and sql . Can you point out my error please . Thanks
 

DonManfred

Expert
Licensed User
Longtime User
You update query is missing a WHERE statement to limit the update to a specific id for example.
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
B4X:
        $q = mysql_query("UPDATE tbldoviz set usd='$d1', usd1='$d2', usd2='$d3', eur='$d4', eur1='$d5', eur2='$d6', chf='$d7', chf1='$d8', chf2='$d9', jpy='$d10', jpy1='$d11', jpy2='$d12', sar='$d13', sar1='$d14', sar2='$d15', gbp='$d16', gbp1='$d17', gbp2='$d18' where id='1');

still getting 500. Maybe i have error somewhere else. I will check the code again.
You update query is missing a WHERE statement to limit the update to a specific id for example.
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
Yes I converted my code as Donmanfred explained and while converting it i fixed it unconciously. But i could not understand why it was giving an error. Now it is clear =) Thanks
you are missing a double quote at the end of the query
 
Upvote 0
Top