Cao, evo mene opet sa mojim problemima
Elem, pravim neki sajtic i sve je islo bez problema dok nije trebalo da napravim stranicu za edit. E sad, i to je islo bez problema sve dok nisam stigla do dela za editovanje ili update slike. Na stranici za edit mi se prikazuju 3 slike. E sad, kada promenim sve 3 slike ne bude nikakvih problema ali kada hocu samo 1 sliku da promenim, izbaci mi gresku. Evo i koda:
Kod:
<?php
require ('mysqli_connect.php');
$page_title = 'Edit';
include ('header.html');
// Check for a valid user ID, through GET or POST:
if ( (isset($_GET['id'])) && (is_numeric($_GET['id'])) ) { // From view_users.php
$id = $_GET['id'];
} elseif ( (isset($_POST['id'])) && (is_numeric($_POST['id'])) ) { // Form submission.
$id = $_POST['id'];
} else { // No valid ID, kill the script.
echo '<p class="error">This page has been accessed in error.</p>';
exit();
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
//Potkresivanje svih primljenih vrednosti
$trimmed = array_map('trim', $_POST);
if (isset($_FILES['upload1'])) {
// Validate the type. Should be JPEG or PNG.
$allowed = array ('image/pjpeg', 'image/jpeg', 'image/JPG', 'image/X-PNG', 'image/PNG', 'image/png', 'image/x-png');
if (in_array($_FILES['upload1']['type'], $allowed)) {
// Move the file over.
if (move_uploaded_file ($_FILES['upload1']['tmp_name'], "includes/uploads/{$_FILES['upload1']['name']}")) {
$i = $_FILES['upload1']['name'];
} // End of move... IF.
} else { // Invalid type.
echo '<p class="error">Please upload a JPEG or PNG image.</p>';
}
} // End of isset($_FILES['upload']) IF.
// Check for an error:
if ($_FILES['upload1']['error'] > 0) {
echo '<p class="error">The file could not be uploaded because: <strong>';
// Print a message based upon the error.
switch ($_FILES['upload1']['error']) {
case 1:
print 'The file exceeds the upload_max_filesize setting in php.ini.';
break;
case 2:
print 'The file exceeds the MAX_FILE_SIZE setting in the HTML form.';
break;
case 3:
print 'The file was only partially uploaded.';
break;
case 4:
print 'No file was uploaded.';
break;
case 6:
print 'No temporary folder was available.';
break;
case 7:
print 'Unable to write to the disk.';
break;
case 8:
print 'File upload stopped.';
break;
default:
print 'A system error occurred.';
break;
} // End of switch.
print '</strong></p>';
} // End of error IF.
if (isset($_FILES['upload2'])) {
// Validate the type. Should be JPEG or PNG.
$allowed = array ('image/pjpeg', 'image/jpeg', 'image/JPG', 'image/X-PNG', 'image/PNG', 'image/png', 'image/x-png');
if (in_array($_FILES['upload2']['type'], $allowed)) {
// Move the file over.
if (move_uploaded_file ($_FILES['upload2']['tmp_name'], "includes/uploads/{$_FILES['upload2']['name']}")) {
$sl = $_FILES['upload2']['name'];
} // End of move... IF.
} else { // Invalid type.
echo '<p class="error">Please upload a JPEG or PNG image.</p>';
}
} // End of isset($_FILES['upload']) IF.
// Check for an error:
if ($_FILES['upload2']['error'] > 0) {
echo '<p class="error">The file could not be uploaded because: <strong>';
// Print a message based upon the error.
switch ($_FILES['upload2']['error']) {
case 1:
print 'The file exceeds the upload_max_filesize setting in php.ini.';
break;
case 2:
print 'The file exceeds the MAX_FILE_SIZE setting in the HTML form.';
break;
case 3:
print 'The file was only partially uploaded.';
break;
case 4:
print 'No file was uploaded.';
break;
case 6:
print 'No temporary folder was available.';
break;
case 7:
print 'Unable to write to the disk.';
break;
case 8:
print 'File upload stopped.';
break;
default:
print 'A system error occurred.';
break;
} // End of switch.
print '</strong></p>';
} // End of error IF.
if ($m && $mo && $k && $g && $gr && $me && $v && $ku && $b && $kl && $p && $p1 && $c1 && $c2 && $c3 &&$c4 &&$c5 &&$c6 && $va && $o && $i && $sl && $bl) { // ako je sve ok
$q = "UPDATE kola SET marka='$m', model='$mo', karoserija='$k', godiste='$g', gorivo='$gr', menjac='$me', vrata='$v', kubikaza='$ku', boja='$b', klasa='$kl', po_gradu='$p', po_putu='$p1', cena1='$c1', cena2='$c2', cena3='$c3', cena4='$c4', cena5='$c5', cena6='$c6', valuta='$va', opis='$o', slika1='$i', slika2='$sl', slika3='$bl' WHERE kola_id=$id LIMIT 1";
$r = @mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error:" . mysqli_error($dbc));
if (mysqli_affected_rows($dbc) == 1) {
header("Location: indexadmin.php");
exit();
}else{
echo '<p class="error">The user could not be edited due to a system error. We apologize for any inconvenience.</p>'; // Public message.
echo '<p>' . mysqli_error($dbc) . '<br />Query: ' . $q . '</p>'; // Debugging message.
}
}
mysqli_close($dbc); // Close the database connection.
// Obrisati fajl ako jos uvek postoji
if (file_exists ($_FILES['upload1']['tmp_name']) && is_file($_FILES['upload1']['tmp_name']) ) {
unlink ($_FILES['upload1']['tmp_name']);
}
if (file_exists ($_FILES['upload2']['tmp_name']) && is_file($_FILES['upload2']['tmp_name']) ) {
unlink ($_FILES['upload2']['tmp_name']);
}
if (file_exists ($_FILES['upload3']['tmp_name']) && is_file($_FILES['upload3']['tmp_name']) ) {
unlink ($_FILES['upload3']['tmp_name']);
}
}
?>
Posto ne mogu da prekopiram ceo kod, zbog velikog broja karaktera, stavila sam samo onaj deo koji je vezan za slike
Gde gresim

Hvala na strpljenju i razumevanju