Subham Sb Subham Sb - 7 months ago 31
SQL Question

Please anyone tell me how to put this php myql query in proper way

I have written the query below but there is no errors and no records are updated
please can anyone correct it.

$db->query("INSERT INTO members (username, password, email)
VALUES ('$username', '$password', '$email')");


using PDO (php Data Object)

     $db_conn = new PDO('mysql:host=localhost;dbname=account','root','password');
    // insert the new member
    $sql = 'INSERT INTO member (username, password, firstname, joinDate)
    VALUES (:username, :password, :firstname, NOW())';
    $stmt = $db_conn->prepare($sql);

// perform query
    ':name' => 'okanlawonE12',
    ':password' => 'okanlawonEmmanuel',
    ':firstname' => 'emmanuel')
// echo last inserted row
    echo "New Member has been added: " . $db_conn->lastInsertId();