I am trying below code for upload multiple image with database using php mysql but not working kindly help me how to upload multiple image in php mysql. and coming error 558d45b0b348a
Notice: Undefined variable: sql in D:\xampp\htdocs\app\db.php on line 37
QUERY FAILED !!!
<?php
session_start();
include_once('configuration.php');
include_once('db.php');
if (isset($_REQUEST['submit'])){
echo $uname = uniqid();
move_uploaded_file($_FILES["shop_img"]["tmp_name"][0],
"uploaded/" . $_FILES["shop_img"]["name"][0]);
$sql="INSERT INTO shop_list ('shop_img')
VALUES (:shop_img);";
$sql_result = $db->queryPrepared($sql,array(
':shop_img' =>$_FILES["shop_img"]["name"][0]
));
$lastId = $db->last_insert_id();
print_r($_FILES);
exit;
foreach($_FILES['shop_img']['name'] as $k=>$v){
$type = $_FILES['shop_img']['type'][$k];
$name = $_FILES['shop_img']['name'][$k];
$temp_name = $_FILES['shop_img']['tmp_name'][$k];
$imgUniqName = uniqid().'.'.$type;
$sqlImg = "INSERT INTO shop_images (shop_id, image)
VALUES (:shop_id, :img_name);";
$sqlImgResult = $db->queryPrepared($sqlImg,array(
':shop_id' => $lastId,
':img_name' => $name
));
move_uploaded_file($temp_name,"uploaded/" . $name);
}
$msg = "<b style='color: green;'>Image upload sucessfully</b>";
}
?>
<form action="" enctype="multipart/form-data" method="post">
<?php if(isset($msg)) echo $msg; ?>
<h3><a>Store Image</a></h3>
<table>
<tr>
<td>Store</td>
<td><input type="file" class="form-control" name="shop_img[]" id="shop_img" required="true" multiple /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Submit" name="submit" class="btn" /></td>
</tr>
</table>
</form>