title: PDO not working function
body: <p>register.php</p>
  
  <pre><code>         &lt;?php
  include_once "pdo.php";
  if(isset($_POST["submit"])){
       $user_pw = hash("sha256", $_POST['password']);
  $params = [
                  'pcode' =&gt; $pcode,
                  'password' =&gt; $user_pw,
                  'name' =&gt; $_POST['name'],
                  'phone' =&gt; $_POST['number'],
                  'grade' =&gt; $_POST['grade']
                  ];
  sql($db, "INSERT INTO member (pcode, password, name, phone, grade) VALUES (:pcode, :password, :name, :phone, :grade)", array($params));
  }
  ?&gt;
  </code></pre>
  
  <p>pdo.php</p>
  
  <pre><code>try {
    $db = new PDO("mysql:host=".HOST.";dbname=".NAME.";charset=utf8", "".USER."", "".PASS."");
    $db-&gt;setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    // PDO fetch docs: http://php.net/manual/en/pdostatement.fetch.php
    $db-&gt;setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
  } catch (PDOException $e) {
    echo $e-&gt;getMessage();
  }
  
  // Simple function to handle PDO prepared statements
  function sql($db, $q, $params, $return) {
  
    // Prepare statement
    $stmt = $db-&gt;prepare($q);
    // Execute statement
    $stmt-&gt;execute($params);
    // Decide whether to return the rows themselves, or just count the rows
    if ($return == "rows") {
      return $stmt-&gt;fetchAll();
    }
    elseif ($return == "count") {
      return $stmt-&gt;rowCount();
    }
  </code></pre>
  
  <p>error </p>
  
  <blockquote>
    <p>Warning: Missing argument 4 for sql(), called in /home/vvvvvv/html/summit/new.php on line 55 and defined in /home/vvvvvv/html/summit/pdo.php on line 19</p>
    
    <p>Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens in /home/vvvvvv/html/summit/pdo.php:24 Stack trace: #0 /home/vvvvvv/html/summit/pdo.php(24): PDOStatement->execute(Array) #1 /home/vvvvvv/html/summit/new.php(55): sql(Object(PDO), 'INSERT INTO mem...', Array) #2 {main} thrown in /home/vvvvvv/html/summit/pdo.php on line 24</p>
  </blockquote>
  
  <p>what's problem?</p>