[php] id in functie wordt fout meegegeven

Pagina: 1
Acties:
  • 99 views sinds 30-01-2008

  • Zym0tiC
  • Registratie: Februari 2001
  • Laatst online: 19:37
Ik heb een probleem bij mijn CMS. Iedere keer dat ik mijn contact.php
pagina wil updaten update hij mijn index2.php pagina.
In de mysql tabel wordt op row 1 alle gegevens van index2.php opgeslagen
($beheer->put(1, $content);) en op row 2 alle gegevens van contact.php
($beheer->put(2, $content);), althans dit zou de bedoeling moeten zijn.
als ik de update query echo dan geeft hij iedere keer een 1 bij ID terwijl ik
toch in de functie een 2 meegeef bij contact.php.

Volgens mij kan het niet iets heel groots zijn omdat het eerst wel werkte
(toen ik nog geen gebruik maakte van classes.)


PHP:
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
// beheer.class.php

class beheer {

    var $table_c;
    var $table_a; 
    var $category;
    

    function put($id, $content) {
        $query = "UPDATE sb_others SET body = '$content' WHERE id = $id"; print($query);
        $result = mysql_query($query);
        if (!$result) {
            die (mysql_error());
        }
        else {
            print( "De bewerking is doorgevoerd." );
        }
    }
    
    
    function edit_hc($id, $title) {
        $query = mysql_query("SELECT * FROM sb_others WHERE id = $id");
        $result = mysql_fetch_object($query);

        print( "<h2>$result->title</h2>" );

        print( "<form action=\"$path?action=edit\" method=\"post\">\n" );
        print( "<center><textarea rows=\"15\" cols=\"75\" name=\"content\">\n" );

        print( "$result->body");;

        print( "</textarea><br /><br />\n" );
        print( "<input type=\"submit\" value=\"Bewerken\" /></center>\n" );
        print( "</form>\n" );
    }

    .......

}
?>



// Index2.php

<?php
require_once("include/header.php");

// Algemene variabelen
$path = "index2.php";
$beheer = new beheer;

switch ($_GET['action']) {
    case edit:
        $content = $_POST['content'];
        $beheer->put(1, $content); 

    // Standaard scherm:
    // Textarea met daarin de index tekst       
    default:
        $beheer->edit_hc(1, "Home");
}       

require_once("include/footer.php");
?>



// Contact.php
<?php
require_once("include/header.php");

// Algemene variabelen
$path = "contact.php";
$beheer = new beheer;

switch ($_GET['action']) {
    case edit:
        $content = $_POST['content'];
        $beheer->put(2, $content); 

    // Standaard scherm:
    // Textarea met daarin de index tekst       
    default:
        $beheer->edit_hc(2, "Contact");
}       

require_once("include/footer.php");
?>

[ Voor 12% gewijzigd door Zym0tiC op 21-04-2004 08:48 ]

There is no such thing as innocence, only degrees of guilt | Flickr!


  • mindcrash
  • Registratie: April 2002
  • Laatst online: 22-11-2019

mindcrash

Rebellious Monkey

Gebruik je die $id variabele ook elders in je beheer object dan als parameter van die 2 functies (of parameter van andere functies)?

[ Voor 16% gewijzigd door mindcrash op 21-04-2004 09:31 ]

"The people who are crazy enough to think they could change the world, are the ones who do." -- Steve Jobs (1955-2011) , Aaron Swartz (1986-2013)


  • whoami
  • Registratie: December 2000
  • Laatst online: 23:32
Het is niet de bedoeling dat wij hier jouw code gaan debuggen hoor.

https://fgheysels.github.io/


Dit topic is gesloten.