title: Android Login and Registration with PHP, MySQL and SQLite forced to close
body: <p><strong>Source of app code</strong> : <a href="http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/" rel="nofollow">http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/</a></p>
  
  <p>I run the apps on my samsung s2 and android 2.2 emulator, both forced to close after I         login with random username and password. It also force to close after I tried to register.</p>
  
  <p><strong>logcat(verbose):</strong></p>
  
  <pre><code>02-21 03:09:15.800: W/KeyCharacterMap(563): No keyboard for id 0
  02-21 03:09:15.800: W/KeyCharacterMap(563): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
  02-21 03:09:23.480: D/Button(563): Login
  02-21 03:09:23.829: E/JSON(563): &lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
  02-21 03:09:23.829: E/JSON(563): &lt;html&gt;&lt;head&gt;
  02-21 03:09:23.829: E/JSON(563): &lt;title&gt;404 Not Found&lt;/title&gt;
  02-21 03:09:23.829: E/JSON(563): &lt;/head&gt;&lt;body&gt;
  02-21 03:09:23.829: E/JSON(563): &lt;h1&gt;Not Found&lt;/h1&gt;
  02-21 03:09:23.829: E/JSON(563): &lt;p&gt;The requested URL /android_login_api/ was not found on this server.&lt;/p&gt;
  02-21 03:09:23.829: E/JSON(563): &lt;/body&gt;&lt;/html&gt;
  02-21 03:09:23.829: E/JSON Parser(563): Error parsing data org.json.JSONException: Value &lt;!DOCTYPE of type java.lang.String cannot be converted to JSONObject
  02-21 03:09:23.829: D/AndroidRuntime(563): Shutting down VM
  02-21 03:09:23.829: W/dalvikvm(563): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
  02-21 03:09:23.849: E/AndroidRuntime(563): FATAL EXCEPTION: main
  02-21 03:09:23.849: E/AndroidRuntime(563): java.lang.NullPointerException
  02-21 03:09:23.849: E/AndroidRuntime(563):  at com.example.androidhive.LoginActivity$1.onClick(LoginActivity.java:65)
  02-21 03:09:23.849: E/AndroidRuntime(563):  at android.view.View.performClick(View.java:2408)
  02-21 03:09:23.849: E/AndroidRuntime(563):  at android.view.View$PerformClick.run(View.java:8816)
  02-21 03:09:23.849: E/AndroidRuntime(563):  at android.os.Handler.handleCallback(Handler.java:587)
  02-21 03:09:23.849: E/AndroidRuntime(563):  at android.os.Handler.dispatchMessage(Handler.java:92)
  02-21 03:09:23.849: E/AndroidRuntime(563):  at android.os.Looper.loop(Looper.java:123)
  02-21 03:09:23.849: E/AndroidRuntime(563):  at android.app.ActivityThread.main(ActivityThread.java:4627)
  02-21 03:09:23.849: E/AndroidRuntime(563):  at java.lang.reflect.Method.invokeNative(Native Method)
  02-21 03:09:23.849: E/AndroidRuntime(563):  at java.lang.reflect.Method.invoke(Method.java:521)
  02-21 03:09:23.849: E/AndroidRuntime(563):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  02-21 03:09:23.849: E/AndroidRuntime(563):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  02-21 03:09:23.849: E/AndroidRuntime(563):  at dalvik.system.NativeStart.main(Native Method)
  02-21 03:14:23.920: I/Process(563): Sending signal. PID: 563 SIG: 9
  02-21 03:49:40.550: W/KeyCharacterMap(600): No keyboard for id 0
  02-21 03:49:40.550: W/KeyCharacterMap(600): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
  02-21 03:49:45.180: D/Button(600): Login
  02-21 03:49:46.750: E/JSON(600): &lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
  02-21 03:49:46.750: E/JSON(600): &lt;html&gt;&lt;head&gt;
  02-21 03:49:46.750: E/JSON(600): &lt;title&gt;404 Not Found&lt;/title&gt;
  02-21 03:49:46.750: E/JSON(600): &lt;/head&gt;&lt;body&gt;
  02-21 03:49:46.750: E/JSON(600): &lt;h1&gt;Not Found&lt;/h1&gt;
  02-21 03:49:46.750: E/JSON(600): &lt;p&gt;The requested URL /android_login_api/ was not found on this server.&lt;/p&gt;
  02-21 03:49:46.750: E/JSON(600): &lt;/body&gt;&lt;/html&gt;
  02-21 03:49:46.750: E/JSON Parser(600): Error parsing data org.json.JSONException: Value &lt;!DOCTYPE of type java.lang.String cannot be converted to JSONObject
  02-21 03:49:46.750: D/AndroidRuntime(600): Shutting down VM
  02-21 03:49:46.760: W/dalvikvm(600): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
  02-21 03:49:46.760: E/AndroidRuntime(600): FATAL EXCEPTION: main
  02-21 03:49:46.760: E/AndroidRuntime(600): java.lang.NullPointerException
  02-21 03:49:46.760: E/AndroidRuntime(600):  at com.example.androidhive.LoginActivity$1.onClick(LoginActivity.java:65)
  02-21 03:49:46.760: E/AndroidRuntime(600):  at android.view.View.performClick(View.java:2408)
  02-21 03:49:46.760: E/AndroidRuntime(600):  at android.view.View$PerformClick.run(View.java:8816)
  02-21 03:49:46.760: E/AndroidRuntime(600):  at android.os.Handler.handleCallback(Handler.java:587)
  02-21 03:49:46.760: E/AndroidRuntime(600):  at android.os.Handler.dispatchMessage(Handler.java:92)
  02-21 03:49:46.760: E/AndroidRuntime(600):  at android.os.Looper.loop(Looper.java:123)
  02-21 03:49:46.760: E/AndroidRuntime(600):  at android.app.ActivityThread.main(ActivityThread.java:4627)
  02-21 03:49:46.760: E/AndroidRuntime(600):  at java.lang.reflect.Method.invokeNative(Native Method)
  02-21 03:49:46.760: E/AndroidRuntime(600):  at java.lang.reflect.Method.invoke(Method.java:521)
  02-21 03:49:46.760: E/AndroidRuntime(600):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  02-21 03:49:46.760: E/AndroidRuntime(600):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  02-21 03:49:46.760: E/AndroidRuntime(600):  at dalvik.system.NativeStart.main(Native Method)
  02-21 03:49:46.840: D/dalvikvm(600): GC_FOR_MALLOC freed 3724 objects / 212248 bytes in 76ms
  02-21 03:49:52.790: I/Process(600): Sending signal. PID: 600 SIG: 9
  02-21 03:51:55.399: W/KeyCharacterMap(748): No keyboard for id 0
  02-21 03:51:55.399: W/KeyCharacterMap(748): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
  02-21 03:52:03.429: D/Button(748): Login
  02-21 03:52:03.759: E/JSON(748): &lt;!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"&gt;
  02-21 03:52:03.759: E/JSON(748): &lt;html&gt;&lt;head&gt;
  02-21 03:52:03.759: E/JSON(748): &lt;title&gt;404 Not Found&lt;/title&gt;
  02-21 03:52:03.759: E/JSON(748): &lt;/head&gt;&lt;body&gt;
  02-21 03:52:03.759: E/JSON(748): &lt;h1&gt;Not Found&lt;/h1&gt;
  02-21 03:52:03.759: E/JSON(748): &lt;p&gt;The requested URL /android_login_api/ was not found on this server.&lt;/p&gt;
  02-21 03:52:03.759: E/JSON(748): &lt;/body&gt;&lt;/html&gt;
  02-21 03:52:03.770: E/JSON Parser(748): Error parsing data org.json.JSONException: Value &lt;!DOCTYPE of type java.lang.String cannot be converted to JSONObject
  02-21 03:52:03.770: D/AndroidRuntime(748): Shutting down VM
  02-21 03:52:03.770: W/dalvikvm(748): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
  02-21 03:52:03.779: E/AndroidRuntime(748): FATAL EXCEPTION: main
  02-21 03:52:03.779: E/AndroidRuntime(748): java.lang.NullPointerException
  02-21 03:52:03.779: E/AndroidRuntime(748):  at com.example.androidhive.LoginActivity$1.onClick(LoginActivity.java:65)
  02-21 03:52:03.779: E/AndroidRuntime(748):  at android.view.View.performClick(View.java:2408)
  02-21 03:52:03.779: E/AndroidRuntime(748):  at android.view.View$PerformClick.run(View.java:8816)
  02-21 03:52:03.779: E/AndroidRuntime(748):  at android.os.Handler.handleCallback(Handler.java:587)
  02-21 03:52:03.779: E/AndroidRuntime(748):  at android.os.Handler.dispatchMessage(Handler.java:92)
  02-21 03:52:03.779: E/AndroidRuntime(748):  at android.os.Looper.loop(Looper.java:123)
  02-21 03:52:03.779: E/AndroidRuntime(748):  at android.app.ActivityThread.main(ActivityThread.java:4627)
  02-21 03:52:03.779: E/AndroidRuntime(748):  at java.lang.reflect.Method.invokeNative(Native Method)
  02-21 03:52:03.779: E/AndroidRuntime(748):  at java.lang.reflect.Method.invoke(Method.java:521)
  02-21 03:52:03.779: E/AndroidRuntime(748):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
  02-21 03:52:03.779: E/AndroidRuntime(748):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
  02-21 03:52:03.779: E/AndroidRuntime(748):  at dalvik.system.NativeStart.main(Native Method)
  02-21 03:52:03.869: D/dalvikvm(748): GC_FOR_MALLOC freed 3885 objects / 218072 bytes in 88ms
  02-21 03:57:03.939: I/Process(748): Sending signal. PID: 748 SIG: 9
  </code></pre>
  
  <p>My database name is android_api, Im using WAMP server just exactly like what androidhive did. Androidhive use below code :</p>
  
  <pre><code>private static String loginURL = "http://10.0.2.2/ah_login_api/";
  private static String registerURL = "http://10.0.2.2/ah_login_api/";
  </code></pre>
  
  <p>but I use this:</p>
  
  <pre><code>private static String loginURL = "http://10.0.2.2/android_login_api/";
  private static String registerURL = "http://10.0.2.2/android_login_api/";
  </code></pre>
  
  <p>and I also try this:</p>
  
  <pre><code>private static String loginURL = "http://10.0.2.2/android_api/";
  private static String registerURL = "http://10.0.2.2/android_api/";
  </code></pre>
  
  <p>I tried 3 URL above but all doesnt work.</p>
  
  <p>I also curious about <strong>config.php</strong>:</p>
  
  <pre><code>&lt;?php
  
  define("DB_HOST", "localhost");
  define("DB_USER", "root");
  define("DB_PASSWORD", "");
  define("DB_DATABASE", "android_api");
  ?&gt;
  </code></pre>
  
  <p>Should i leave DB_PASSWORD just like that? because i dont know / dont have the password.</p>
  
  <p>I succesfully run this app <a href="http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/" rel="nofollow">http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/</a> on android 2.2 emulator.</p>
  
  <p>But getting problem with this login and registration app.</p>
  
  <p>This is my first time on developing android project, hope there are expertise could help me to solve this problem. I tried hard to solve this for whole 2 days but nothing.</p>
  
  <p>I checked every single code by many times, but I don't know the causes of the force close.</p>
  
  <p><em>Please guide and show me the true.</em>
  *Thanks*</p>