Beste mensen,
Ik zit echt met een heel vaag probleem. Ik kan bepaalde gegevens niet updaten maar wel adden en in PHPmyAdmin kan ik ze ook editen ik kan het probleem niet echt vinden.
<?php
//connect with the db
require_once 'inc/connect.php';
error_reporting(E_ALL);
//getting the posted information
$id = htmlspecialchars($_POST['id']);
$name = htmlspecialchars($_POST['name']);
$price = htmlspecialchars($_POST['price']);
$category = htmlspecialchars($_POST['category']);
$discription = $_POST['text'];
$image= strtolower($_FILES['image']['name']);
if($image != NULL){
//Variables needed for uploadImage function:
$img_ff = 'image';
$dst_path = '../articles/';
$dst_img = strtolower($_FILES['image']['name']);
$dst_cpl = $dst_path . basename($dst_img);
if((uploadImage($img_ff, $dst_path, $dst_img)) == true){
//Variables needed for resizeImage function:
$src_img = $dst_img;
$dst_img = preg_replace('/\.[^.]*$/', '', $src_img) . '_thumb.jpg';
$src_path = $dst_path;
$dst_path = '../articles/thumbs/';
$dst_w = '150';
$dst_h = '150';
$dst_quality = '100';
if((resizeImage($src_img, $dst_img, $src_path, $dst_path, $dst_w, $dst_h, $dst_quality)) == false){
die ('<p>Could not resize the image</p>');
}
}else{
die ('<p>Could not upload the image</p>');
}
$query = "UPDATE article SET name='$name', price='$price', discription='$discription', image='$image', thumb='$dst_path$dst_img', category='$category' WHERE id='$id'";
if (!mysql_query($query)){
die('<h1>Something went wrong!!</h1><p>The article has not been edit because of this following mysql error : ' . mysql_error() . '</p>');
}else{
echo '<h1>Edit Succesfully</h1>';
echo '<p>The article "' . $name . '" has been edit succesfull</p>';
echo '<p><a href="art.index.php">Click here to go to the article </a></p>';
}
}else{
$query = "UPDATE article SET name='$name', price='$price', discription='$discription', category='$category' WHERE id=$id";
if (!mysql_query($query))
{
die('<h1>Something went wrong!!</h1><p>The article has not been edit because of this following mysql error : ' . mysql_error() . '</p>');
}else{
echo '<h1>Edit Succesfully</h1>';
echo '<p>The article "' . $name . '" has been edit succesfull</p>';
echo '<p><a href="art.index.php">Click here to go to the article </a></p>';
}
}
?>
1.356 views