There is a form, in it there are 2 fields, the name and address, and a button for uploading files (pictures) to the server. The idea is that the picture itself would fall into the upload folder, and the link to the picture in the url_img field. Picture table. prntscr.com/d6rqmd and prntscr.com/d6rqur. The script I found in foreach, but its work itself is clear to me in principle, but it doesn’t work out to make this script work yet.
Here is my code:
<form enctype="multipart/form-data" action="" method="post"> <label>Название</label> <input type="text" name="title" value=""> <label>Адресс</label> <input type="text" name="address" > <label>Загрузить фоновую фотографию</label> <input type="file" name="pictures[]" > <input type="submit" name="upload" value="Сохранить"> </form> if($_POST['upload']) { $url_img = $_POST['url_img']; $title = $_POST['title']; $address = $_POST['address']; if($title || $address !== "") { $add = mysql_query("INSERT INTO stores VALUES ('', '$title', '$address')") or die(mysql_error()); header("Location: /admin/admin.php?page=all_stores"); } foreach ($_FILES["pictures"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["pictures"]["tmp_name"][$key]; $name = $_FILES["pictures"]["name"][$key]; $kod=uniqid(); move_uploaded_file($tmp_name, "../upload".$kod.$name); $imgmedia="../upload".$kod.$name; $queryup = "UPDATE stores SET $url_img = '{$imgmedia}'"; $result = mysql_query($queryup); } } } The code for downloading files is in foreach. Now I get an error, Column count doesn't match value count at row 1. Tell me what's wrong with this script? Can somehow change the structure of the code or something wrong with the fields? Why is this {$ imgmedia} variable in braces?
"INSERT INTO stores VALUES ('', '$title', '$address')this place, swears at the lack of columns - DaVASrK"UPDATE stores SET $url_img = '{$imgmedia}'"why do you need$url_imghere? Change tourl_imgif I understood correctly. And when inserting what I wrote above, in those columns that are updated later, put a list just "". In general, it is better to specify which line the error now indicates? - DaVASrK