Advertisement
hombretao

bind_param

Oct 6th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.66 KB | None | 0 0
  1. <?
  2. newUser( 2, 'aksjds', 'pass' );
  3.  
  4. function newUser( $email, $parent, $hash )
  5. {
  6.     $db = db();
  7.  
  8.     $sql =
  9.     "INSERT INTO users
  10.     ( email, parent, joindate, hash )
  11.     VALUES
  12.     ( ?, ?, now(), ? )
  13.     ";
  14.  
  15.     if( $query = $db->prepare( $sql ) )
  16.     {
  17.         $bind = $query->bind_param( 'sis', $email, $parent, $hash );
  18.  
  19.         if( $bind === false )
  20.         {
  21.             die( 'bind_param() failed: ' . htmlspecialchars( $query->error ) );
  22.         }
  23.  
  24.         $execute = $query->execute();
  25.  
  26.         if ( $execute === false )
  27.         {
  28.             die( 'execute() failed: ' . htmlspecialchars( $query->error ) );
  29.         }
  30.  
  31.         $query->close();
  32.     }
  33.     else
  34.     {
  35.         die( 'prepare() failed: ' . htmlspecialchars( $db->error ) );
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement