4. Android PHP MySQL Tutorial | User Registration PHP Script




Here is a Complete Step by Step Android PHP MySQL Tutorial. This tutorial will cover all the basics of connecting Android Application to MySQL Database.

Original source


49 responses to “4. Android PHP MySQL Tutorial | User Registration PHP Script”

  1. help !!

    Fatal error: Uncaught Error: Call to a member function bind_param() on bool in C:xampphtdocsandroidtestconnectserverincludesDbOperations.php:15 Stack trace: #0 C:xampphtdocsandroidtestconnectserverv1registerUser.php(20): DBOperations->createUser('admin1', 'admin1@hotmail….', 'admin1') #1 {main} thrown in C:xampphtdocsandroidtestconnectserverincludesDbOperations.php on line 15

    Thank !!

  2. if you have same problem about $conn->prepare or $stmt->bind_param, i have any argument (modify)

    <?php

    class DbOperations {

    // private $con;

    function _construct() {

    }

    // function connect() {
    // require_once dirname(_FILE_) . '/DbConnect.php';
    // $db = new DbConnect();
    // $this->con = $db->connect();
    // }
    //
    // /* CRUD -> C -> CREATE */

    function createUser($username, $pass, $email) {

    $password = md5($pass);
    // $stmt = $this->con->prepare("INSERT INTO `users` (`id`, `username`, `password`, `email`) VALUES (NULL, ?, ?, ?);");
    // $stmt->bind_param("sss",$username,$pass,$email);
    //
    // if ($stmt->execute()) {
    // return true;
    // } else {
    // require false;
    // }
    $DB_HOST = "localhost";
    $DB_USER = "root";
    $DB_PASSWORD = "";
    $DB_NAME = "android";

    // Create connection
    $conn = new mysqli($DB_HOST, $DB_USER, $DB_PASSWORD, $DB_NAME);

    // Check connection
    if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
    }

    // prepare and bind
    $stmt = $conn->prepare("INSERT INTO `users` (`id`, `username`, `password`, `email`) VALUES (NULL, ?, ?, ?);");
    $stmt->bind_param("sss", $username, $pass, $email);
    if ($stmt->execute()) {
    return true;
    } else {
    require false;
    }
    }

    }

    ?>

  3. while running the register.php the below error occurs. kindly guide me sir.
    <br />
    <b>Fatal error</b>: Uncaught Error: Call to a member function prepare() on null in C:xampphtdocsAndroidIncludesDbOperations.php:21
    Stack trace:
    #0 C:xampphtdocsAndroidv1registerUser.php(21): DbOperations-&gt;createUser('sid', '1234', 'sid@gmail.com')
    #1 {main}
    thrown in
    <b>C:xampphtdocsAndroidIncludesDbOperations.php</b> on line
    <b>21</b>
    <br />

  4. sir I use the source code of the PHP from your link, and when I register user using postman post It reply {"error":true,"message":"Some error occurred please try again"}

    I already follow your video but it keeps on giving me that error

  5. one thing is display the one warning also warning</b>: mysqli::__construct(): php_network_getaddresses: getaddrinfo failed: No such host is known. in
    <b>F:xampphtdocsandroidincludesDbConnect.php</b> on line
    <b>13</b>
    what is this sir, means my host name is not found or what?

  6. I Got Error
    Fatal error: Uncaught Error: Call to a member function bind_param() on boolean in C:webhtdocsAndroidincludesdbOperations.php:16 Stack trace: #0 C:webhtdocsAndroidv1registerUser.php(19): dbOperations->createUser(
    .
    .
    Why?

  7. Parse error: syntax error, unexpected 'function_construct' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in C:xampphtdocsandroidincludeDbOperation.php on line 9 help me to solve this error

  8. Object not found!
    The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.

    If you think this is a server error, please contact the webmaster.

    Error 404
    localhost
    Apache/2.4.33 (Win32) OpenSSL/1.1.0g PHP/7.2.4
    plz help me to solve this……
    i will be very thankfull to you for this

  9. How can i connect this app to my database online at godaddy? Your code/app works on my localhost (local machine), but when i try to connect to the same database structure located at my godaddy webserver account, it does not seem to respond at all. The toast message contains empty. Please help.

  10. i got the error
    Warning: require_once(Android/includes/DbOperations.php): failed to open stream: No such file or directory in C:xampphtdocsAndroidv1registerUser.php on line 3

    Fatal error: require_once(): Failed opening required 'Android/includes/DbOperations.php' (include_path='C:xamppphpPEAR') in C:xampphtdocsAndroidv1registerUser.php on line 3

  11. please heeellpppp

    in my phpadmin, the only i'm recieving a "?" for username, "0" for my password, and "?" for my email.

    Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement in C:xampphtdocsandroidincludesDbOperation.php on line 17
    {"error":false,"message":"User registered succesfully"}

  12. plz give me the solution for this error

    Fatal error: Uncaught Error: Call to a member function prepare() on null in C:xampphtdocsChatBotDbOperation.php:16 Stack trace: #0 C:xampphtdocsChatBotRegisterUser.php(20): DbOperation->createUser('ronak', 'f78cc277bfc0f69…', '12345') #1 {main} thrown in C:xampphtdocsChatBotDbOperation.php on line 16

  13. Warning: mysqli_stmt::bind_param(): Number of variables doesn't match number of parameters in prepared statement in C:xampphtdocsAndroidincludesDbOperations.php on line 22
    {"ERROR":false,"message":"User registered successfully"}

  14. For all of those who are having the problem that postman is returning "Required fields are missing" (or wathever you indicated), what means that the server is not receiving values, do the following: In postman, DON´T push 'params' and add the params. Despite of this, go to the tab 'Body' (clickable when 'POST' method is selected) and then insert the values from there, selecting 'form-data' or 'x-www-form-urlencoded'. Hope it helps. It worked for me.

  15. I am getting an error with postman as are others i see but i dont see any decent answer. I get the error:

    <b>Warning</b>: require_once(../includes/DbOperations.php): failed to open stream: No such file or directory in
    <b>C:xampphtdocsAndroidv1registerUser.php</b> on line 3

    also i changed the directory to the full link to see if it would work and i get this:

    <b>Warning</b>: require_once(C:xampphtdocsAndroidincludes): failed to open stream: Permission denied in
    <b>C:xampphtdocsAndroidv1registerUser.php</b> on line
    <b>3</b>

Leave a Reply