Loading...

Android MySQL Database Tutorial 1 - Creating Database And Writing PHP Script

Android MySQL Database Tutorial 1 - Creating Database And Writing PHP Script
Hi welcome to this short series on Android MySQL Database Tutorial for beginners. In Android PHP/MySQL Tutorial I will use PHP to create a back-end rest server. In this first video I will show How to Create your MySQL Database And Writing  PHP Script. It is the Best tutorial for android PHP and MySQL. This tutorial series will cover  How to connect Android app to MySQL database?, Android Tutorial - Connect Android to MySQL Database, Android Login and Registration with PHP, MySQL , Android Login Form Tutorial with MySQL and PHP

-------------------Online Courses to learn----------------------------
Java - https://bit.ly/2H6wqXk
C++ - https://bit.ly/2q8VWl1
AngularJS - https://bit.ly/2qebsLu
Python - https://bit.ly/2Eq0VSt
C- https://bit.ly/2HfZ6L8
Android - https://bit.ly/2qaRSAS
Linux - https://bit.ly/2IwOuqz
AWS Certified Solutions Architect - https://bit.ly/2JrGoAF
Modern React with Redux - https://bit.ly/2H6wDtA
MySQL - https://bit.ly/2qcF63Z
----------------------Follow---------------------------------------------
My Website - http://www.codebind.com
My Blog - https://goo.gl/Nd2pFn
My Facebook Page - https://goo.gl/eLp2cQ
Google+ - https://goo.gl/lvC5FX
Twitter - https://twitter.com/ProgrammingKnow
Pinterest - https://goo.gl/kCInUp
Text Case Converter - https://goo.gl/pVpcwL
-------------------------Stuff I use to make videos -------------------
Stuff I use to make videos
Windows notebook – http://amzn.to/2zcXPyF
Apple MacBook Pro – http://amzn.to/2BTJBZ7
Ubuntu notebook - https://amzn.to/2GE4giY
Desktop - http://amzn.to/2zct252
Microphone – http://amzn.to/2zcYbW1
notebook mouse – http://amzn.to/2BVs4Q3
------------------Facebook Links ----------------------------------------
http://fb.me/ProgrammingKnowledgeLearning/
http://fb.me/AndroidTutorialsForBeginners
http://fb.me/Programmingknowledge
http://fb.me/CppProgrammingLanguage
http://fb.me/JavaTutorialsAndCode
http://fb.me/SQLiteTutorial
http://fb.me/UbuntuLinuxTutorials
http://fb.me/EasyOnlineConverter

RRelated Posts

CComments

  • pool Anthony Estupinan Cuero
    Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\login.php on line 7
    login not success
  • Batul Arthuna
    adding mysql library in android takes more space than adding sqlite??
  • JD Coding 101
    What if i am running it on my physical android device?
  • Mostafa Ashrafi
    thank u a lot. i just follow the videos and it works for me
  • Anonymous
    sir which is the ide u use for coding php
  • denny soni
    sir thank you so much for this serices ...but sir how can i use only one time login..pls help me
  • Muzafar Seyed
    This is super duper awesome...
  • sharbel p i b
    thank you man
    this is great, although I don't know how to code in php but I've understood the concept..
    the problem in other tutorials that they either too easy so they aren't usefull or too hard to be understood by beginners, but this's exactly the right level to an android programmer who's not expert in php,sql and other networking stuff
    tnx again 😁😀
  • Malik Hassan Qayyum
    login.php 21:05
  • Malik Hassan Qayyum
    php script 12:40
  • SmartTech
    any alternative to php scripts? I dont know php, can anyone please recommend other language, thanks in advance
  • ABHIJEET THAKRE
    some of you may get the error
    Warning: mysql_num_rows() expects parameter 1 to be resource, null given in C:\xampp\htdocs\login.php on line 7Try changing the name of the table in line 5,he wrote employee_data ,whereas i had written employeedata
  • codingknowledge
    Can we use mysql in local network in android
  • SHIVAM KUMAR GUPTA
    hello sir i am this year doing according to you please solve the error Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given
  • Woraprat Mindo
    Thank you
  • NaturallyRoro
    When I check the connection I keep getting this message " Parse error: syntax error, unexpected '"root"' (T_CONSTANT_ENCAPSED_STRING) in C:\wamp64\www\conn.php on line 3", can someone explain why that is happening and what I can do to correct it. Thanks in advance
  • little programmer
    please do you have a vedio how to read the dsata into list view
  • Hasan Irshad
    Hi!
    Can you explain how to make logout method?
  • Tanveer Hasan
    sound quality is to much poor.
  • little programmer
    please how can i get the source code
  • pvzgaming
    will this still work with api 26
  • Sumesh Kumar
    best ever starting and understanding sir thankyou sir
  • Albin Thomas MCA 2016-2019
    main activity
    package com.example.anit.studmanager;
    import android.app.Activity;
    import android.content.DialogInterface;
    import android.content.Intent;
    import android.os.Bundle;
    import android.support.v7.app.AlertDialog;
    import android.view.KeyEvent;
    import android.view.View;
    import android.widget.Button;
    import android.widget.ImageButton;


    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.app.Activity;
    import android.content.Intent;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import com.example.anit.studmanager.R;
    import com.example.anit.studmanager.StudentDetails;
    import com.example.anit.studmanager.ViewDetails;

    public class MainActivity extends Activity {
    Button badd,bview;
    ImageButton im;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    badd=(Button)findViewById(R.id.button);
    bview=(Button)findViewById(R.id.button2);
    im=(ImageButton)findViewById(R.id.button5);
    badd.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    Intent stud = new Intent(MainActivity.this, StudentDetails.class);
    startActivity(stud);
    }
    });
    bview.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    Intent view = new Intent(MainActivity.this, ViewDetails.class);
    startActivity(view);

    }
    });


    }
    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
    AlertDialog.Builder ad = new AlertDialog.Builder(MainActivity.this);
    ad.setTitle("Confirm Exit");
    ad.setMessage("do U want to Exit");
    ad.setIcon(R.drawable.myhome);
    ad.setPositiveButton("OK", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {

    finish();
    // android.os.Process.killProcess(android.os.Process.myPid());
    //super.onDestroy();
    // System.exit(1);
    }
    });
    ad.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
    @Override
    public void onClick(DialogInterface dialog, int which) {

    dialog.cancel();
    }
    });
    ad.show();



    }
    return super.onKeyDown(keyCode, event);
    }
    /* @Override
    public void onBackPressed() {
    if (this.isFinishing()){
    finish();

    // super.onBackPressed();
    }
    }*/

    }

    student

    package com.example.anit.studmanager;

    import android.content.Context;
    import android.database.sqlite.SQLiteDatabase;
    import android.database.sqlite.SQLiteOpenHelper;


    import android.content.Context;
    import android.database.sqlite.SQLiteDatabase;
    import android.database.sqlite.SQLiteOpenHelper;
    /**
    * Created by ANIT on 8/10/2016.
    */

    public class Student extends SQLiteOpenHelper {
    public static final String DB_NAME="StudentDB";
    public static final int VERSION_NO=1;
    public static final String TABLE_NAME="studDetails";
    public static final String ID="id";
    public static final String ROLL_NO="rno";
    public static final String NAME="username";
    public static final String BRANCH="bran";
    public static final String SCORE="sr";
    public Student(Context con) {
    super(con,DB_NAME,null,VERSION_NO);
    }
    @Override
    public void onCreate(SQLiteDatabase db) {
    String createTable = "CREATE TABLE "+TABLE_NAME+" ("+ID+" INTEGER PRIMARY KEY AUTOINCREMENT," +
    ""+ROLL_NO+" TEXT NOT NULL,"+NAME+" TEXT NOT NULL,"+BRANCH+" TEXT NOT NULL,"+SCORE+" FLOAT NOT NULL)";
    db.execSQL(createTable);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }

    }
    student details

    package com.example.anit.studmanager;
    import android.app.Activity;
    import android.content.ContentValues;
    import android.content.Context;
    import android.content.Intent;
    import android.database.sqlite.SQLiteDatabase;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.KeyEvent;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.ImageButton;
    import android.widget.Toast;

    public class StudentDetails extends Activity {
    EditText rn,nm,br,sc;
    Button save;
    ImageButton im;
    Context mcontext;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_student_details);
    mcontext=this;
    rn=(EditText)findViewById(R.id.editText);
    nm=(EditText)findViewById(R.id.editText2);
    br=(EditText)findViewById(R.id.editText3);

    sc=(EditText)findViewById(R.id.editText4);
    im=(ImageButton)findViewById(R.id.button5);
    save=(Button)findViewById(R.id.button3);

    save.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {

    String roll=rn.getText().toString();
    String name=nm.getText().toString();
    String bran=br.getText().toString();
    float score=Float.parseFloat(sc.getText().toString());
    rn.setText("");
    nm.setText("");
    br.setText("");
    sc.setText("");

    Student dbHelp=new Student(mcontext);
    SQLiteDatabase db=dbHelp.getWritableDatabase();

    ContentValues value=new ContentValues();
    value.put(Student.ROLL_NO,roll);
    value.put(Student.NAME,name);
    value.put(Student.BRANCH,bran);
    value.put(Student.SCORE,score);
    long n= db.insert(Student.TABLE_NAME,null,value);

    Toast.makeText(mcontext,"Inserted at" +n,Toast.LENGTH_LONG).show();




    }
    });


    im.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    Intent view = new Intent(StudentDetails.this, MainActivity.class);
    startActivity(view);
    }
    });

    }
    /*@Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {

    Intent view = new Intent(StudentDetails.this, MainActivity.class);
    startActivity(view);

    }
    return super.onKeyDown(keyCode, event);
    }*/

    }
  • Jin Sheng
    hi, can I use MySQL workbench instead of phpMyAdmin? I have setup my MySQL workbench for now, and I just need to connect my current MySQL workbench with my Android
  • Francesco Zappala'
    Does it work if the computer is turned off?
  • louay hesham
    ( ! ) Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given on line 7
  • Abstruse Afio
    <?php

    require "conn.php";
    $user_name = "afio";
    $password = "9234008690";
    $mysql_qry = "select * from students_data where username like '$user_name' and password like '$password';";

    $result = mysqli_query($conn ,$mysql_qry);
    if(mysqli_num_rows($result) > 0) {
    echo "login success";
    }
    else {
    echo "login not success";
    }
    ?>
    What is wrong in this code.it ain't running.
  • abhay paul
    when i try to view the result it shows an error in 'localhost/userlogin.php' which show " Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\wamp64\www\userlogin.php on line 7"
  • OnlyPromo O
    showing error in 8 line
  • ahsan shakir
    sir how can i fetch data in listview. please uploads the videos for fetching and i am searching for fetching but i am not understanding the concept.please help me friend
  • benlo335
    guys this work for me :)

    <?php
    $db_name = "user";
    $mysql_username = "root";
    $mysql_password = "";
    $server_name = "localhost";
    $conn = mysqli_connect($server_name, $mysql_username, $mysql_password, $db_name);
    $user_name = "admin";
    $user_pass = "admin";
    $mysql_qry = "SELECT * FROM user_data WHERE username = '$user_name' AND password = '$user_pass'";
    $result = mysqli_query($conn, $mysql_qry);
    $row_cnt = $result->num_rows;
    if ($row_cnt == 1) {
    echo "login success";
    } else {
    echo "login fail";
    }
    ?>
  • Virendra Ahire
    guys i got an error can anyone please fix it :-
    mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\login.php on line 8
    not success.
  • Josh Regio
    i found a fix for the error in mysqli_num_rows.
    Just change the if(mysqli_num_rows($result>0)) to if(mysqli_num_rows($result))
  • Mayank Goyal
    I shuldn't be saying this but this video is nassal .... sala naak se padha raha h ..... it is very irritating to learn thorugh this specific video
  • Ittipon Kankaew
    help !

    Parse error: syntax error, unexpected '$result' (T_VARIABLE) in C:\wamp64\www\login.php on line 6

    //mycode
    <?php
    require "conn.php";
    $user_name = "";
    $user_pass = "";
    $mysql_qry = "select * from employee_data where username like '$user_name' and password like '$user_password';"
    $result = mysqli_query($conn ,$mysqli_qry);
    if(mysqli_num_rows($result) > 0) {
    echo "login success";
    }
    else{
    echo "login not success";
    }
    ?>
  • Charbel Sarkis
    sound is way too low
  • SPY Enterprises
    Hi sir,
    Please make a video how to create app locker android app.
  • Jaspreet Singh
    Error while reading greeting packet. PID=13436 in C:\wamp64\www\conn.php on line 6

    <?php
    $db_name = "mydb";
    $mysql_username = "root";
    $mysql_password = "";
    $server_name = "localhost:8080";
    $conn = mysqli_connect($server_name, $mysql_username, $mysql_password, $db_name);
    if($conn)
    {
    echo "sucess";
    }
    else
    {
    echo "failure";
    }
    ?>

    any solutions?
  • spring green
    how do i create the next activity on the login button?
  • Junaid Khan
    Sir please make one video
    Login Android app using MySQL database & php after login user see the our information in navigation drawer name field and also see the name or photo
    And how to upload image using in registeration form.

    Please reply sir and you also send project my email address is
    khanjunaid046@gmail.com
  • khalid almustafa
    Thanks
  • Ryan Garcia
    Parse error: syntax error, unexpected '$user_name' (T_VARIABLE) in F:\xampp\htdocs\login.php on line 3
  • Farly Wuwungan
    still error:
    <?php
    require "conn.php";
    $user_name = "123";
    $user_pass = "123";
    $mysql_qry = "select * from users_data where username like '$user_name' and password like '$user_pass';";
    $result = mysql_query($conn,$mysql_qry);
    if(mysqli_num_rows($result) > 0) {
    echo "login success";
    } else {
    echo "login not success";
    }
    ?>

    Warning: mysql_query() expects parameter 1 to be string, object given in C:\wamp64\www\bank_sampah\login.php on line 6
    Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in C:\wamp64\www\bank_sampah\login.php on line 7

    can anyone help?
  • ronnie mmola
    i recognise your voice sir, i think you made a tutorial on how to convert a website into an app using WebView, i love all your tutorials sir, they are very helpful
  • balaji.k balaji.k
    how to create login form for using roll number and date of birth to login succeed.
  • Abhishek Rajpurohit
    they said connection is success login not success
    what should i do
  • V sick
    is it okay to do it on wamp server 3?
  • Christo Naudé
    Just by the way Like is a bad command when checking passwords in mysql use =
  • Namakemono Lyn
    Good video. Thanks for doing it.
  • Aleksy Ruszała
    Is it bad to use DB connection without JSON ?