Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9200053
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:40:47+00:00 2026-06-17T22:40:47+00:00

I am working on a simple app where I sign up new users. –

  • 0

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.

Please help. I have searched a lot and could not resolve the errors.

I am getting following errors:

ERROR

This is my actual error now
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;}

Slim Application Error

The application could not run because of the following error:

Details:

Message: error_log(/var/tmp/php.log) [function.error-log]: failed to open stream: No such file or directory
File: C:\xampp\htdocs\api\index.php
Line: 105

Stack Trace:

#0 [internal function]: Slim::handleErrors(2, ‘error_log(/var/…’, ‘C:\xampp\htdocs…’, 105, Array)
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…’)
01-27 08:42:14.981: D/URL read(6739): #2 [internal function]: register()
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)
01-27 08:42:14.981: D/URL read(6739): #4 C:\xampp\htdocs\api\Slim\Slim.php(1052): Slim_Route->dispatch()
01-27 08:42:14.981: D/URL read(6739): #5 C:\xampp\htdocs\api\index.php(26): Slim->run()
01-27 08:42:14.981: D/URL read(6739): #6 {main}

RegisterActivity.java(partial)

          class CreateNewUser extends AsyncTask<String, String, String> {

    /**
     * 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<NameValuePair> params = new ArrayList<NameValuePair>();
        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();
    }

}

jsonParser.java(partial)

       public JSONObject makeHttpRequest(String url, String method,
        List<NameValuePair> 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;

}

SLIM :index.php

<?php

session_start(); 
require 'Slim/Slim.php';

$app = new Slim();


$app->post('/login', 'login');

$app->post('/register', 'register');

$app->response()->header('Content-Type', 'application/json');

$app->get('/users', 'getUsers');
$app->get('/users/:id', 'getUser');
$app->get('/users/search/:query', 'findByName');
$app->post('/users', 'addUser');
$app->put('/users/:id', 'updateUser');
$app->delete('/users/:id',  'deleteUser');


$app->get('/gametype', 'getgameType');



$app->run();




// AUTHENTICATION START


function login() {
    $request = Slim::getInstance()->request();
    $user = json_decode($request->getBody());
    $email= $user->email;
    $password= $user->password;
    // echo $email;
//   echo $password;
if(!empty($email)&&!empty($password))
    {
        $sql="SELECT email, fname, role FROM tbl_user WHERE email='$email' and password='$password'";
        $db = getConnection();


    try {
        $result=$db->query($sql); 

                if (!$result) { // add this check.
                      die('Invalid query: ' . mysql_error());
                }
        $row["user"]= $result->fetchAll(PDO::FETCH_OBJ);
        $db=null;
        echo json_encode($row);

    } catch(PDOException $e) {
        error_log($e->getMessage(), 3, '/var/tmp/php.log');
        echo '{"error":{"text":'. $e->getMessage() .'}}'; 
    }

    }

} 

// AUTHENTICATION END

//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$



// Register START


function register() {

    $request = Slim::getInstance()->request();
    $user = json_decode($request->getBody());
    $sql = "INSERT INTO tbl_user (email, password, fname) VALUES (:email, :password, :fname)";
    try {
        $db = getConnection();
        $stmt = $db->prepare($sql);  
        $stmt->bindParam("fname", $user->fname);
        $stmt->bindParam("password", $user->password);
        $stmt->bindParam("email", $user->email);
        $stmt->execute();
        $user->id = $db->lastInsertId();
        $db = null;


        print('{"success":1}');

    } catch(PDOException $e) {
        error_log($e->getMessage(), 3, '/var/tmp/php.log');
        echo '{"error":{"text":'. $e->getMessage() .'}}'; 
    }
}

    // Register END

Behavior of APP: After clickng signup buttom…app gets stuck here and crashes as “Unfortunately, yourapp has stopped.”..

AppSCREEN

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:40:49+00:00Added an answer on June 17, 2026 at 10:40 pm

    When the Slim response object is first created, it sets a content type of “text/html”.

    Maybe in your register() method, you should do something like:

    function register()
    {
        $request = Slim::getInstance()->request();
        $response = Slim::getInstance()->response();
        $response['Content-Type'] = 'application/json; charset=utf-8';
    
        /* rest of your function here*/
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a simple app to aid learning database with Apache.Derby and working
I'm new to rails and I'm working on a simple app where users create
I am working on a simple budget app using Sinatra and DataMapper in Ruby.
Relatively new to rails, I'm working on a simple rails app for a few
I'm new to Rails and I'm working through a simple app that has the
I'm fairly new to programming in general. I'm working on a simple app that
I am working on a really simple app that is styled using twitter-bootstrap-rails. One
OK, well I've been working on a simple app that allows users to save
Currently i am working in simple game app using openGLES, draw a line using
I am working on a simple app in Sinatra with DataMapper. I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.