I have this long PHP page which is suppose to insert data into a MySQL database. Some of the fields may be null and some may have text to input into. Once the code inserts the information from the form, I want it to open up the newest record in the table(one that was just inserted) and then create a folder and move the uploaded images into it. I get the error that no index was created for each field when the PHP code runs. Here is the code:
[php]<?php
include("…/…/…/db/db_connection.php");
error_reporting(E_ALL);
ini_set(‘display_errors’, ‘1’);
$img1 = $_FILES[‘img1’][‘name’];
$img2 = $_FILES[‘img2’][‘name’];
$img3 = $_FILES[‘img3’][‘name’];
$img4 = $_FILES[‘img4’][‘name’];
$img5 = $_FILES[‘img5’][‘name’];
$img6 = $_FILES[‘img6’][‘name’];
$img7 = $_FILES[‘img7’][‘name’];
$sql = “INSERT INTO Vehicles_TBL VALUES (’$_POST[category]’,’$_POST[year]’,’$_POST[make]’,’$_POST[model]’,’$_POST[series]’,’$img1’,’$img2’,’$img3’,’$img4’,’$img5’,’$img6’,’$img7’,’$_POST[price]’,’$_POST[vin]’,’$_POST[stocknumber]’,’$_POST[color]’,’$_POST[mileage]’,’$_POST[engine]’,’$_POST[transmission]’,’$_POST[airbag1]’,’$_POST[airbag2]’,’$_POST[brakes]’,’$_POST[antitheft]’,’$_POST[powersteering]’,’$_POST[powerwindows]’,’$_POST[powerlocks]’,’$_POST[powermirrors]’,’$_POST[cruisecontrol]’,’$_POST[amfmstereo]’,’$_POST[cdplayer]’,’$_POST[tintedglass]’,’$_POST[floormats1]’,’$_POST[floormats2]’,’$_POST[readinglamp1]’,’$_POST[readinglamp2]’,’$_POST[drivetrain]’,’$_POST[headlightsautoonoff]’,’$_POST[wheels]’,’$_POST[seating]’,’$_POST[powerseat1]’,’$_POST[powerseat2]’,’$_POST[rearwindow]’,’$_POST[heatedseats]’,’$_POST[featuredvehicle]’,’$_POST[sunroof]’,’$_POST[moonroof]’,’$_POST[other]’)”;
$result = mysql_query($sql);
if (!$sql)
{
die('Could not connect: ’ . mysql_error());
}
$result1 = mysql_query(“SELECT * FROM Vehicles_TBL ORDER BY VID LIMIT 0, 1”);
while($row = mysql_fetch_array($result1))
{
mkdir("…/…/…/img/" . $row[‘Category’] . “/” . $row[‘Year’] . “" . $row[‘Make’] . "” . $row[‘VID’] . “/”);
$target_path = “…/…/…/img/” . $row[‘Category’] . “/” . $row[‘Year’] . “" . $row[‘Make’] . "” . $row[‘VID’] . “/”;
$target_path1 = $target_path . basename($_FILES[‘img1’][‘name’]);
move_uploaded_file($_FILES[‘img1’][‘tmp_name’], $target_path));
$target_path2 = $target_path . basename($_FILES[‘img2’][‘name’]);
move_uploaded_file($_FILES[‘img2’][‘tmp_name’], $target_path));
$target_path3 = $target_path . basename($_FILES[‘img3’][‘name’]);
move_uploaded_file($_FILES[‘img3’][‘tmp_name’], $target_path));
$target_path4 = $target_path . basename($_FILES[‘img4’][‘name’]);
move_uploaded_file($_FILES[‘img4’][‘tmp_name’], $target_path));
$target_path5 = $target_path . basename($_FILES[‘img5’][‘name’]);
move_uploaded_file($_FILES[‘img5’][‘tmp_name’], $target_path));
$target_path6 = $target_path . basename($_FILES[‘img6’][‘name’]);
move_uploaded_file($_FILES[‘img6’][‘tmp_name’], $target_path));
$target_path7 = $target_path . basename($_FILES[‘img7’][‘name’]);
move_uploaded_file($_FILES[‘img7’][‘tmp_name’], $target_path));
}
?>[/php]