Youssef El Garny
Youssef El Garny

Reputation: 65

sending plain text with space from an EditText to a mysql db?

Please i am trying to send from an EditText a text with space between words but nothing inserted in my db !

and when i send a text with no space works and inserted !

please what is the problem here ??

MyAsyncTaskresources attemptLogin= new MyAsyncTaskresources();
attemptLogin.execute("http://xxx.xxxxx.com/add_demande.php?de="+infos_demande.getStringExtra("de").toString()+"&a="+infos_demande.getStringExtra("a").toString()+"&date="+infos_demande.getStringExtra("date").toString()+"&heur="+infos_demande.getStringExtra("heur").toString()+"&id_user="+infos_demande.getStringExtra("id_conducteur"+i).toString());

Upvotes: 0

Views: 76

Answers (4)

kingmaker
kingmaker

Reputation: 59

You need to Encode the String values using URLEncoder.encode(<Query Value>,"UTF-8") before appending the values to the URL String.

MyAsyncTaskresources attemptLogin= new MyAsyncTaskresources();                 
attemptLogin.execute("http://xxx.xxxxx.com/add_demande.php?de="+URLEncoder.encode(infos_demande.getStringExtra("de").toString(),"UTF-8")+"&a="+URLENcoder.encode(infos_demande.getStringExtra("a").toString(),"UTF-8")+"&date="+URLEncoder.encode(infos_demande.getStringExtra("date").toString(),"UTF-8")+"&heur="+URLEncoder.encode(infos_demande.getStringExtra("heur").toString(),"UTF-8")+"&id_user="+URLEncoder.encode(infos_demande.getStringExtra("id_conducteur"+i).toString(),"UTF-8"));

Upvotes: 0

Mosa
Mosa

Reputation: 381

using volley is best and fast than use this old process

volley library in android , can send request and get response easy and adding parameter such as string and no problem of space , and there is handle for server error to check where your error

Upvotes: 0

washichi
washichi

Reputation: 100

First make your code readable, build your string before putting it in attemptLogin.execute(...)

now you have your string build you can check your string, try that and make sure your attemptLogin.execute() argument is a legit string!

Upvotes: 0

Maksym V.
Maksym V.

Reputation: 2937

Have you try adding

 N'

as a first part of the string?

Upvotes: 1

Related Questions