0

I want to fill some items from a database into a form as soon as somebody presses a button. Therefore I wrote some functions, which are saving the id of the row in my database (this id is transmitted from the button) and then converting them into a fetch_object. This fetch_Object then is supposed to get filled in the text-input fields of a form.

I am using XAMPP.



function showEditForm($row) {
    var_dump($row);
    $name = $row->name;
    $bewertung = $row->bewertung;
    $bemerkung = $row->bemerkung;

    echo <<<ENDE
        <form action="main.php">
        <form action="phpinfo.php" method="POST">
        Name:<br>
            <input type="text" name="name" value="$name"><br>
        Bewertung (1-6):<br>
            <input type="number" name="bewertung" min="1" max="6" value="$bewertung"><br>
        Bemerkung:<br>
            <input type="text" name="bemerkung" value="$bemerkung">
            <input type="submit" value="senden">

</form> 
ENDE;
}

if ($function == "edit") {
        $id = $_GET['editEntry2'];
        echo "id: $id <br>";
        $row = $kneipen->selectOne($id);
        print_r($row);
        showEditForm($row);
        showEditForm($id);
    } else {
        showList();
    }

    function nextRow(){
        if (!$this->result) {
            return false;       
        }
        $row = $this->result->fetch_object();
        return $row;
    }

    function selectOne($id){
        $sql = "SELECT * FROM kneipen WHERE id = '$id'";
        // echo "sql = $sql <br\>";
        $this->result = $this->mysqli->query($sql); 
        if (!$this->result) {
                echo("Errorcode: " . $this->mysqli->errno . " " . $this->mysqli->error);        
        }
        return $this->nextRow(); 
    }


Notice: Trying to get property 'name' of non-object in C:\Praktikanten\Elias\Programme\xampp-windows-x64-7.3.10-0-VC15\xampp\htdocs\Projekt KneipenDB\functionGUI.php on line 67

Notice: Trying to get property 'bewertung' of non-object in C:\Praktikanten\Elias\Programme\xampp-windows-x64-7.3.10-0-VC15\xampp\htdocs\Projekt KneipenDB\functionGUI.php on line 68

Notice: Trying to get property 'bemerkung' of non-object in C:\Praktikanten\Elias\Programme\xampp-windows-x64-7.3.10-0-VC15\xampp\htdocs\Projekt KneipenDB\functionGUI.php on line 69

  • 1
    You appear to have **2** `
    ` tags one after the other
    – RiggsFolly Oct 22 '19 at 10:53
  • is this a class? You refer to $this, but it just looks like you have some functions, unless this is just a code fragment. can you clarify? – delboy1978uk Oct 22 '19 at 10:55
  • And you call `showEditForm()` twice and at least once using a parameter that is obviously not an object. Based on this line `$id` cannot be an object `$id = $_GET['editEntry2'];` – RiggsFolly Oct 22 '19 at 10:57
  • yes there is a class. the functions are from another document with a class. but the fact, that i called showEditForm() twice was the mistake. Thx @RiggsFolly – Elias Gleditzsch Oct 22 '19 at 11:10
  • Possible duplicate of [Reference - What does this error mean in PHP?](https://stackoverflow.com/questions/12769982/reference-what-does-this-error-mean-in-php) – Can O' Spam Oct 22 '19 at 11:12

0 Answers0