Android Tutorial Connect Android to MySQL Database Tutorial

Status
Not open for further replies.

Walter Scafati

Active Member
Licensed User
Longtime User
Just do it but nothing.

The problem is always the same: the query sent from app to the php page is empty.
 

Walter Scafati

Active Member
Licensed User
Longtime User
Yes, I use this server for a php application for my company. Now I want to connect to data stored in the same mysql database with an android app.
 

Ricardo Gonzalez Gaete

Member
Licensed User
Longtime User
Hi'

I'm developing an application but when I try to connect to the remote server, the error in the application Java.net.socketimeoutexception
Call code via browser and appears this.

Warning: mysqli_connect(): (HY000/2003): Can't connect to MySQL server on '200.28.130.15' (110) in /home/kreasoft/public_html/php/maestro.php on line 8

Warning: mysqli_error() expects parameter 1 to be mysqli, boolean given in /home/kreasoft/public_html/php/maestro.php on line 8


Estoy ocupando el siguiente código de PHP

<?php
$databasehost = "??????";
$databasename = "????";
$databaseusername ="???";
$databasepassword = "?????";
$con = mysqli_connect($databasehost,$databaseusername,$databasepassword, $databasename) or die(mysqli_error($con));
mysqli_set_charset ($con , "utf8");
$query = file_get_contents("php://input");
$sth = mysqli_query($con, $query);
if (mysqli_errno($con)) {
header("HTTP/1.1 500 Internal Server Error");
echo $query.'\n';
echo mysqli_error($con);
}
else
{
$rows = array();
while($r = mysqli_fetch_assoc($sth)) {
$rows[] = $r;
}
$res = json_encode($rows);
echo $res;
mysqli_free_result($sth);
}
mysqli_close($con);
?>

I am doing wrong please help

 

Myr0n

Active Member
Licensed User
Longtime User
The phpcode works like a charm, but if you aren't entered the good information in the beginning of the phpcode doesn't gonna work.
If you think that the error is coming from your b4a code you should start a new thread and post your b4a code to help you out.
 
Last edited:

LWGShane

Well-Known Member
Licensed User
Longtime User
The following query works in PHPMyAdmin, but not in B4J:

B4X:
SELECT *
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA LIKE  'mydb'
ORDER BY  `TABLES`.`TABLE_NAME`

Any ideas?
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…