I am new to PhP. I am trying to delete some rows from my sqlite database, but I can't figure out what is wrong. My code is as below:
<?php
$app_name=array("TestApp", "MyDataBase");
$dir = 'sqlite:/home/ravi/public_html/GcmServer/FavoriteApps.db';
$dbh= new PDO($dir) or die("cannot open the database");
for($i=0;$i<sizeof($app_name);$i++) {
error_log("looop start here...............");
error_log("FirstAppName ".$app_name[$i]);
$result= $dbh->Query("DELETE FROM favorite_apps WHERE appname = '$app_name[$i]'") or die( error_log("error".mysql_error() ));
error_log("looop execute here...............");
}
?>
And my log file is like this:
[Wed Sep 19 11:16:38 2012] [error] [client 127.0.0.1] looop start here...............
[Wed Sep 19 11:16:38 2012] [error] [client 127.0.0.1] FirstAppName TestApp
[Wed Sep 19 11:16:38 2012] [error] [client 127.0.0.1] error
and my localhost show 1,
thanks.
mysql_errorcannot see errors that happened in PDO. UsePDO::errorInfoinstead. And look into prepared statements.