Insert into table with prepared statement

后端 未结 3 767
攒了一身酷
攒了一身酷 2021-01-24 19:32

I\'m trying to insert data from a form into a database using PHP and Mysqli but I can\'t get it working! My database has 4 fields: DATE, TITLE, CONTENT, ID. The ID field is auto

3条回答
  •  余生分开走
    2021-01-24 20:13

    Since you are aware about prepared statement:

    $newBlog = $mysqli->prepare('INSERT INTO Blog (`dateCol`, `titleCol`, `contentCol`) VALUES (?, ?, ?)');
    $newBlog->bind_param( 'sss', $blogDate, $_POST["bTitle"], $_POST["bContent"] );
    $newBlog->execute();
    $newBlog->close();
    

提交回复
热议问题