Here is my code to upload a file. Everything is working perfect. This code uploads the file to destination folder and MySQL query work perfect and insert all data into their relative fields in database. But it is not going to the page which is mentioned in header() function. It gives me an error at the end like this
Error: please try again, You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1' at line 1
I think it occurs when last if($exe) is executed
<?php
include('./includes/connection.php');
if(!$_POST['song_name']){
header('location: pro_add.php');
exit;
}
$path = "../upload_data/";
$uniqid = uniqid(strtotime('now'));
$uniq_name = $uniqid .'_'. $_FILES['file']['name'];
$complete_path = $path . $uniq_name;
$move = move_uploaded_file($_FILES['file']['tmp_name'],$complete_path);
if(!$move){
echo 'Error: please try again'."<br/>";
}
$query = mysql_query("INSERT INTO products SET
sub_cat_id='".$_POST['sub_cat_id']."',
song_name='".$_POST['song_name']."',
artist='".$_POST['artist']."',
path='".$complete_path."' ");
$exe = mysql_query($query);
if($exe){
header('location: products.php');
exit;
}else{
echo 'Error: please try again, <br />' . mysql_error();
}
?>