I have an android app that runs a PHP script to insert some rows into a MySQL table on my home server. I need to perform some debugging for which I have placed some "echo" commands at strategic locations within my PHP script. However, since the script is being triggered by an Android app on my phone, I obviously can't view the results of those echo commands in my browser. Is there any workaround?
For what it's worth, here's the PHP script in question:
<?php
// Includes
require_once 'PROJdbconn.php';
// Run script only if the dump array is received
if($_POST){
echo "
Entries received: ".count($_POST)."
"; // TEST1: Get POST size
// Read POST array
$arr = 0;
foreach($_POST as $entry){
$tempentry = $entry;
$namenum = explode(",",$tempentry);
$names[$arr] = str_replace("_", " ", $namenum[1]);
$numbers[$arr] = preg_replace('/[^0-9]/','',$namenum[0]);
$arr += 1;
}
$namenum = NULL;
echo "
Entries after parse: ".$arr."
"; // TEST2: Get parse count
// Build SQL query
$sql = "INSERT INTO Contact_table (PHONE, NAME) VALUES ";
for ($i = 0; $i < $arr; ++$i){
$sql .= "('".$numbers[$i]."', '".$names[$i]."'),";
echo $i.". ".$numbers[$i]."--->".$names[$i]."
"; // TEST3: dump names and numbers
}
$i = NULL;
$arr = NULL;
$names = NULL;
$numbers = NULL;
$sql = substr($sql,0,strlen($sql)-1)." ON DUPLICATE KEY UPDATE name = COALESCE(VALUES(name), name);";
// Connect to MySQL database
$connect = dbconn(PROJHOST,PROJDB,PROJDBUSER,PROJDBPWD);
// Execute SQL query
$query = $connect->query($sql);
$sql = NULL;
$query = NULL;
// Close connection to MySQL database
$connect = NULL;
}
?>
You can use a google chrome extension that can POST data to this PHP script. the extensions name is Postman - REST Client. Its a very easy tool to use :).