I am running Raspbian on a Pi and installed Apache, Php5 and sqlite I am inserting some values into sqlite table through php web page, but I am not able to insert though I can upload the file
Following is the Simple Following PHP code.
Note:- Same works on WAMP smoothly. Please suggest the solution.
Thanks in Advance.
<?php
if (!empty($_POST['btnUploadAlbum']))
{
$dir = 'sqlite:test.sqlite';
//echo $userName . $emailId . $msg;
// echo "success opens";
$db = new PDO($dir) or die("cannot open the database");
echo "DB opens";
$dirName='Albums/Album';
if (!file_exists($dirName)) {
mkdir($dirName, 777,true);
}
if(!empty($_POST['AlbumName']))
{
$dirName=$dirName . $_POST['AlbumName'];
if (!file_exists($dirName)) {
mkdir($dirName, 777,true);
}
if (isset($_FILES['fileuploadSong']['name'])) {
$fileName = $_FILES['fileuploadSong']['name'];
if(strpos($fileName,'.mp3') or strpos($fileName,'.mp4'))
{
$dirName = $dirName."/". basename($fileName);
// echo $dirName;
if (move_uploaded_file($_FILES['fileuploadSong']['tmp_name'], $dirName))
{
echo "in 1";
$statement = "INSERT INTO AlbumFiles (SongName,SongPath) values ('$fileName','$dirName')";
echo $statement;
$db->exec($statement) or die("not executed");
echo '<script language="javascript">';
echo 'alert("'.$fileName.' uploaded successfully sent");';
echo '</script>';
echo "in 2 executed";
}
}
else
{
echo '<script language="javascript">';
echo 'alert("Please upload Mp3/Mp4 files!")';
echo '</script>';
}
}
}
}
?>
die("not executed")
? – CL. Sep 2 '14 at 13:08