I am invoking a PHP script from and Android client. Here is the PHP script
<?php
//$user = $_GET['username'];
//$timestamp = $_GET['timestamp'];
//$latitude = $_GET['latitude'];
//$longtitude = $_GET['longtitude'];
//$filename = $_GET['filename'];
$user = "test";
$timestamp = 100;
$latitude = 10;
$longtitude = 10;
$filename = "test.jpg";
$dbname = "sqlite:/".dirname(__FILE__)."/terrapin";
$handle = new PDO($dbname);
if (!$handle) die ($error);
error_log("before exec",0);
$insert = "INSERT INTO information VALUES(NULL,'$user','$latitude','$longtitude','$timestamp','$filename')";
$handle->exec($insert);
error_log("after exec",0);
$handle = null;
$total = $user."\n".$timestamp."\n".$latitude."\n".$longtitude;
$name = "dumpp.txt";
$fh = fopen($name, 'w');
fwrite($fh,$total);
fclose($fh);
?>
The problem is, when I run the script from the command line, it works fine and inserts into the db. But when I remove the comments and get the values from the GET request and invoke the script from the client, nothing gets inserted into the db. There is nothing in the error, however both the error_log statements get printed. Any idea why this is happening?
$db = new SQLite3("terrapin"); $db->exec($insert);