User Registration using Slim Rest server and android client <p>I am working on a simple app where I sign up new users. - I am using SLIM PHP framework with MySQL on apache local host - I have a MySQL database with table called tbl_user. I have tested my SLIM implementation using CURL - On Client side, I have three EditView fields named fname, email and password and a sign up button - Its simple, when user click sign up button, the db connection should be made and new user should be added in database. Registration is simple w/o any checks. That I am going to implement once I resolve this issue.</p> <p>Please help. I have searched a lot and could not resolve the errors.</p> <p>I am getting following errors:</p> <p>ERROR</p> <p>This is my actual error now<br> 01-27 08:42:14.981: D/URL read(6739): Slim Application Errorbody{margin:0;padding:30px;font:12px/1.5 Helvetica,Arial,Verdana,sans-serif;}h1{margin:0;font-size:48px;font-weight:normal;line-height:48px;}strong{display:inline-block;width:65px;}<h1>Slim Application Error</h1><p>The application could not run because of the following error:</p><h2>Details:</h2><strong>Message:</strong> error_log(/var/tmp/php.log) [function.error-log]: failed to open stream: No such file or directory<br/><strong>File:</strong> C:\xampp\htdocs\api\index.php<br/><strong>Line:</strong> 105<br/><h2>Stack Trace:</h2>#0 [internal function]: Slim::handleErrors(2, 'error_log(/var/...', 'C:\xampp\htdocs...', 105, Array)<br /> 01-27 08:42:14.981: D/URL read(6739): #1 C:\xampp\htdocs\api\index.php(105): error_log('SQLSTATE[23000]...', 3, '/var/tmp/php.lo...')<br /> 01-27 08:42:14.981: D/URL read(6739): #2 [internal function]: register()<br /> 01-27 08:42:14.981: D/URL read(6739): #3 C:\xampp\htdocs\api\Slim\Route.php(392): call_user_func_array('register', Array)<br /> 01-27 08:42:14.981: D/URL read(6739): #4 C:\xampp\htdocs\api\Slim\Slim.php(1052): Slim_Route->dispatch()<br /> 01-27 08:42:14.981: D/URL read(6739): #5 C:\xampp\htdocs\api\index.php(26): Slim->run()<br /> 01-27 08:42:14.981: D/URL read(6739): #6 {main}</p> <p>RegisterActivity.java(partial)</p> <pre><code> class CreateNewUser extends AsyncTask&lt;String, String, String&gt; { /** * Before starting background thread Show Progress Dialog * */ @Override protected void onPreExecute() { super.onPreExecute(); pDialog = new ProgressDialog(RegisterActivity.this); pDialog.setMessage("Signing Up.."); pDialog.setIndeterminate(false); pDialog.setCancelable(true); pDialog.show(); } /** * Creating User * */ protected String doInBackground(String... args) { String fname = mUsername.getText().toString(); String email = mEmail.getText().toString(); String password = mPassword.getText().toString(); // Building Parameters List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); params.add(new BasicNameValuePair("email", email)); params.add(new BasicNameValuePair("password", password)); params.add(new BasicNameValuePair("fname", fname)); // getting JSON Object // Note that create user url accepts POST method JSONObject json = jsonParser.makeHttpRequest(url_create_product, "POST", params); // check log cat from response //Log.d("Create Response", json.toString()); // check for success tag try { int success = json.getInt(TAG_SUCCESS); if (success == 1) { // successfully created USER Intent i = new Intent(getApplicationContext(), UserHome.class); startActivity(i); // closing this screen // finish(); } else { // failed to create USER // Log.d("No Sign Up.", json.toString()); } } catch(JSONException e){ // Log.e("log_tag", "Error parsing data "+e.toString()); // Log.e("log_tag", "Failed data was:\n" + TAG_SUCCESS); } return null; } /** * After completing background task Dismiss the progress dialog * **/ protected void onPostExecute(String file_url) { // dismiss the dialog once done pDialog.dismiss(); } } </code></pre> <p>jsonParser.java(partial)</p> <pre><code> public JSONObject makeHttpRequest(String url, String method, List&lt;NameValuePair&gt; params) { // Making HTTP request try { // check for request method if(method == "POST"){ // request method is POST // defaultHttpClient DefaultHttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost(url); httpPost.setEntity(new UrlEncodedFormEntity(params)); HttpResponse httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity(); is = httpEntity.getContent(); }else if(method == "GET"){ // request method is GET DefaultHttpClient httpClient = new DefaultHttpClient(); String paramString = URLEncodedUtils.format(params, "utf-8"); url += "?" + paramString; HttpGet httpGet = new HttpGet(url); HttpResponse httpResponse = httpClient.execute(httpGet); HttpEntity httpEntity = httpResponse.getEntity(); is = httpEntity.getContent(); } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } try { BufferedReader reader = new BufferedReader(new InputStreamReader( is, "iso-8859-1"), 8); StringBuilder sb = new StringBuilder(); String line = null; while ((line = reader.readLine()) != null) { sb.append(line + "\n"); } is.close(); json = sb.toString(); } catch (Exception e) { Log.e("Buffer Error", "Error converting result " + e.toString()); } // try parse the string to a JSON object try { jObj = new JSONObject(json); } catch (JSONException e) { Log.e("JSON Parser", "Error parsing data " + e.toString()); } // return JSON String return jObj; } </code></pre> <p>SLIM :index.php</p> <pre><code>&lt;?php session_start(); require 'Slim/Slim.php'; $app = new Slim(); $app-&gt;post('/login', 'login'); $app-&gt;post('/register', 'register'); $app-&gt;response()-&gt;header('Content-Type', 'application/json'); $app-&gt;get('/users', 'getUsers'); $app-&gt;get('/users/:id', 'getUser'); $app-&gt;get('/users/search/:query', 'findByName'); $app-&gt;post('/users', 'addUser'); $app-&gt;put('/users/:id', 'updateUser'); $app-&gt;delete('/users/:id', 'deleteUser'); $app-&gt;get('/gametype', 'getgameType'); $app-&gt;run(); // AUTHENTICATION START function login() { $request = Slim::getInstance()-&gt;request(); $user = json_decode($request-&gt;getBody()); $email= $user-&gt;email; $password= $user-&gt;password; // echo $email; // echo $password; if(!empty($email)&amp;&amp;!empty($password)) { $sql="SELECT email, fname, role FROM tbl_user WHERE email='$email' and password='$password'"; $db = getConnection(); try { $result=$db-&gt;query($sql); if (!$result) { // add this check. die('Invalid query: ' . mysql_error()); } $row["user"]= $result-&gt;fetchAll(PDO::FETCH_OBJ); $db=null; echo json_encode($row); } catch(PDOException $e) { error_log($e-&gt;getMessage(), 3, '/var/tmp/php.log'); echo '{"error":{"text":'. $e-&gt;getMessage() .'}}'; } } } // AUTHENTICATION END //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ // Register START function register() { $request = Slim::getInstance()-&gt;request(); $user = json_decode($request-&gt;getBody()); $sql = "INSERT INTO tbl_user (email, password, fname) VALUES (:email, :password, :fname)"; try { $db = getConnection(); $stmt = $db-&gt;prepare($sql); $stmt-&gt;bindParam("fname", $user-&gt;fname); $stmt-&gt;bindParam("password", $user-&gt;password); $stmt-&gt;bindParam("email", $user-&gt;email); $stmt-&gt;execute(); $user-&gt;id = $db-&gt;lastInsertId(); $db = null; print('{"success":1}'); } catch(PDOException $e) { error_log($e-&gt;getMessage(), 3, '/var/tmp/php.log'); echo '{"error":{"text":'. $e-&gt;getMessage() .'}}'; } } // Register END </code></pre> <p>Behavior of APP: After clickng signup buttom...app gets stuck here and crashes as "Unfortunately, yourapp has stopped."..</p> <p><img src="https://i.stack.imgur.com/Kbwsx.jpg" alt="AppSCREEN"></p>