Hello.
I develop an ionic application that communicates with a database stored on my computer.
when i run my application on my machine with the command ionic lab, any function perfectly but when i install the apk on a mobile, i have the message unable to connect to the server.
how can I fix this error
the error that appears on the phone is:
“Application error
the connection to the server was unsuccessfull
file: ///android_asset/www/index.html
”
I connect my application to the server with php and I use this statement “this.http.get (” http: //localhost/sw/connexion.php “);” to connect to the database.
the contents of the connection.php file is as follows:
<? Php
// Define database connection parameters
$ hn = 'localhost';
$ a = 'root';
$ pwd = '';
$ db = 'sw';
$ cs = 'utf8';
// Set up the PDO parameters
$ dsn = "mysql: host =". $ hn. "; port = 3306; dbname =". $ db. "charset =". $ Cs;
$ opt = array (
PDO :: ATTR_ERRMODE => PDO :: ERRMODE_EXCEPTION,
PDO :: ATTR_DEFAULT_FETCH_MODE => PDO :: FETCH_OBJ,
PDO :: ATTR_EMULATE_PREPARES => false,
);
// Create a PDO instance (connect to the database)
$ pdo = new PDO ($ dsn, $ un, $ pwd, $ opt);
?>
Search the forum and or google for this error message. This indicates that the Cordova app being generated can not open your Ionic app running inside it. What device are you testing on? Do you have a newer, faster one? If not, there is a timeout value you can set - searching for that error message should give it to you quite easily.