Kan niet editen in PHP script

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Ruben

Ruben

24/11/2008 17:32:00
Quote Anchor link
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.

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?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>';
    }
}


?>
 
PHP hulp

PHP hulp

19/04/2024 18:07:49
 
Tikkes C

Tikkes C

24/11/2008 17:42:00
Quote Anchor link
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
<?PHP
$query
= "UPDATE article SET name='$name', price='$price', discription='$discription', image='$image', thumb='$dst_path$dst_img', category='$category' WHERE id='$id'";
?>



verander naar:


Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
<?PHP
$query
= "UPDATE article
SET
name='"
.$name."',
price='"
.$price."',
discription='"
.$discription."',
image='"
.$image."',
thumb='"
.$dst_path$dst_img."',
category='"
.$category."'
WHERE
id="
.$id."";
?>


ik denk trouwens dat die thumb niet klopt
 
Ruben

Ruben

24/11/2008 19:57:00
Quote Anchor link
het werkt niet maar ik krijg nog steeds geen foutmelding of iets dergelijks.
 
Joren de Wit

Joren de Wit

24/11/2008 20:00:00
Quote Anchor link
En waar controleer jij of er wel daadwerkelijk records geupdate zijn? Gebruik mysql_affected_rows() na je update query om dat te bepalen...
 
Ruben

Ruben

25/11/2008 20:33:00
Quote Anchor link
@blanche hij geeft nu aan dat hij 0 affected rows heeft. hoe kan dat?
 
Klaasjan Boven

Klaasjan Boven

25/11/2008 20:36:00
Quote Anchor link
Ruben schreef op 25.11.2008 20:33:
@blanche hij geeft nu aan dat hij 0 affected rows heeft. hoe kan dat?


Er zijn geen rijen bijgewerkt
doe eens

echo $query;
 
Ruben

Ruben

25/11/2008 20:48:00
Quote Anchor link
Oke hij doet het. Ik had een id uit een verkeerde tabel gepost.. heel handig :S
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.