Skip to content

PHP Connection issues related to the LoginPHPMySQL #142

@infyProductions

Description

@infyProductions

I had a lot of database connection issues while trying out this project. After I started XAMMP (with Apache and MySQL only) and trying to run the application. The android part of the tutorial works but when I tried to connect my phone (as a test device) to the webserver hosted on my machine, it returns an error pertaining to "Unable to retrieve any data from server".

I tried browsing on http://localhost/test_android/index.php when it returned an error like:
Fatal error: Uncaught ArgumentCountError: mysqli_connect_errno() expects exactly 0 arguments, 1 given in D:\XAMPP\htdocs\test_android\db-connect.php:13 Stack trace: #0 D:\XAMPP\htdocs\test_android\db-connect.php(13): mysqli_connect_errno(Object(mysqli)) #1 D:\XAMPP\htdocs\test_android\user.php(12): DbConnect->__construct() #2 D:\XAMPP\htdocs\test_android\index.php(31): User->__construct() #3 {main} thrown in D:\XAMPP\htdocs\test_android\db-connect.php on line 13

I also checked the logcat logs of the app and it returned a similar error like the one on the top:
E/API123: 200
D/API123:

Fatal error: Uncaught ArgumentCountError: mysqli_connect_errno() expects exactly 0 arguments, 1 given in D:\XAMPP\htdocs\test_android\db-connect.php:13
Stack trace:
#0 D:\XAMPP\htdocs\test_android\db-connect.php(13): mysqli_connect_errno(Object(mysqli))
#1 D:\XAMPP\htdocs\test_android\user.php(12): DbConnect->__construct()
#2 D:\XAMPP\htdocs\test_android\index.php(31): User->__construct()
#3 {main}
thrown in D:\XAMPP\htdocs\test_android\db-connect.php on line 13

E/JSON Parser: Error parsing data org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject

I checked the questionable line and it looks like this:
Line 13: if (mysqli_connect_errno($this->connect)){
Line 14: echo "Unable to connect to MySQL Database: " . mysqli_connect_error();
Line 15: }

I used the default credentials on XAMMP with the DB_HOST set as localhost.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions