I successfully configured ACRA to send my caught exceptions to my server, the problem is I can't insert the report into the database:
@AcraCore(buildConfigClass = BuildConfig.class)
@AcraHttpSender(uri = "http://www.myserver.com/crashreports/addreport.php",
httpMethod = HttpSender.Method.POST)
public class MyApplication extends Application {
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
ACRA.init(this);
}
}
I know it sends somethings because I see an empty entry in my phpMyAdmin
, but I can't get the report inside the database:
<?php
$link = mysqli_connect("localhost", "root", "pass", "db");
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Escape user inputs for security
$report = mysqli_real_escape_string($link, $_REQUEST['']);
// attempt insert query execution
$sql = "INSERT INTO VoiceRemoteCrash (report) VALUES ('$report')";
if(mysqli_query($link, $sql)){
echo "Records added successfully.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
// close connection
mysqli_close($link);
?>
I've searched docs, but didn't find much info, and my PHP
knowledge is somewhat basic.
$_REQUEST['']
will returns NULL
and will throw an "undefined index" notice.
You could get your report from POST raw data using file_get_contents('php://input')
.
I suggest you to have a look to : How can I prevent SQL injection in PHP? and use parameterized queries.