Guys, how can I update the database in RedBean ? When entering an article, he sees her id and some fields from the database, but when you press the button, the id becomes 0:

$id = R::load('addsub', $item['id']); echo $id; if(isset($_POST['save'])) { R::exec("UPDATE addsub SET title='$data[title]' WHERE `id` ='$id'"); } 

If you put for example id = 1, then everything works

    1 answer 1

    It seems something like this :) I advise you to read the redbeanphp directories, because it will be more difficult in the future!

     $id = $_POST['id']; $user = R::load('addsub',$id]) if(isset($_POST['save'])){ $user->title=$data['title']; $id = R::store($user); 
    • if it doesn’t work, then you probably need to remove $ id before recording - KeZA3D