php - Unable to INSERT a row in a table with PDO -


i want insert data table using pdo. looked examples , found need use functions prepare, bind , execute, can not figure out in code doing wrong because inserted nothing , have no error in query or php code.

    if($_post){      $account    = $_post['account'];     $password   = $_post['password'];     $phone      = $_post['phone'];     $email      = $_post['email'];      $stmt =     'insert employer(account, password, phone, email) values(:account, :password, :phone, :email)';     $stmt = $conn->prepare($stmt);      $stmt->bindparam(':account', $account, pdo::param_str,100);     $stmt->bindparam(':password',$password, pdo::param_str,100);     $stmt->bindparam(':phone', $phone, pdo::param_str,100);     $stmt->bindparam(':email', $email, pdo::param_str,100);      if ($stmt->execute(array('account'  => $account,                              'password' => $password,                              'phone'    => $phone,                              'email'    =>$email                              )                         )         ){     echo "success";     }else{         echo "error";     }  } 

error detected @jeroen binding twice. can bind "either bind before execute statement or send array parameter, not both"

$stmt = $pdo->prepare(' insert employer (account, password, phone, mail) values (:account, :password, :phone, :mail)');    $stmt->execute(              array(':account'    => $account,                    ':password'   => md5($password),                    ':phone'      => $phone,                   ':mail'        => $email                   )             );    if ($pdo->lastinsertid())     return true;   else    return false; 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -