Forum Moderators: coopster
loop works on its own but with the insert sql code its ignored?.
$sql = "insert into brokerage (type, price, make, model, year, engine_type, engine_hrs, fuel, LOA, beam, accommodation, brief, description, finance, warranty, date, maxspeed, lying) values ('$type', '$price', '$make', '$model', '$year', '$engine_type', '$engine_hrs', '$fuel', '$LOA', '$beam', '$accommodation', '$brief', '$description', '$finance', '$warranty', '$date', '$maxspeed', '$lying')";
$result = mysql_query($sql, $conn);
$boatID = mysql_insert_id();
// image uploader
$uploaddir = 'uploads/';
$tot = count($userfile);
$num = 0;
print "test";
for($q=0;$q<$tot;$q++){
$picture[$q] = $_FILES['userfile']['tmp_name'][$q];
if ($_FILES['userfile']['name'][$q] == "") continue;
print "test";
$picturename[$q] = "".uniqid(I).".jpg";
move_uploaded_file($_FILES['userfile']['tmp_name'][$q], $uploaddir . $picturename[$q]);
$filepath = 'uploads/' .$picturename[$q];
$sqlimage = "update brokerage
set picture".$num." = '$filepath'
where id = $boatID";
$resultimage = mysql_query($sqlimage, $conn);
if (!$resultimage) {
print "There was a database error when executing <pre>$sqlimage</pre>";
print mysql_error();
exit;
$num = $num + 1;
}
}
[edited by: jatar_k at 4:37 pm (utc) on Jan. 16, 2004]
[edit reason] fixed sidescroll [/edit]