Inserting into database using a PDO

后端 未结 4 1035
借酒劲吻你
借酒劲吻你 2021-01-23 02:08

I\'m trying to insert data into a database that I have on my server.

To connect to my database I have the following code:



        
4条回答
  •  终归单人心
    2021-01-23 02:58

    Here are some syntax rules to follow:

    The SQL query must be quoted in PHP String values inside the SQL query must be quoted Numeric values must not be quoted The word NULL must not be quoted

     If(isset($_POST['submit'])) {
    
    $stmt = $db->prepare("INSERT INTO usersdata (Firstname, Lastname, 
    Email,Passward)
    VALUES (:name, :lstname, :email,:pass)");
    
    // inserting a record
    

    then Bind the Values with your variables it will work

提交回复
热议问题