Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Aug 11th, 2018 57 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. How can I change this code to show WHY an insert failed? PHP, MySQLi, Prepared Statements
  2. $dbc = mysqli_connect(DB_HOST, DB_USER, DB_USER_PASSWORD, DB_NAME) or die(DB_CONNECT_ERROR);
  3.     if (!$stmt = mysqli_prepare($dbc, $query)) die('SEL:mysqli_prepare');
  4.     call_user_func_array('mysqli_stmt_bind_param', array_merge(array($stmt, 'sssssssssssssssssssssbsssss')), $idb);
  5.     mysqli_stmt_execute($stmt);
  6.  
  7.     if (!mysqli_stmt_affected_rows($stmt)) {
  8.             // Failed to insert
  9.     } else {
  10.             // Success
  11.             }
  12.    
  13. mysqli_stmt_execute($stmt);
  14.  
  15. printf("Error #%d: %s.n", mysqli_stmt_errno($stmt), mysqli_stmt_error($stmt));
  16.    
  17. if(mysqli_stmt_affected_rows($stmt) == 0)
  18.    
  19. if(!mysqli_stmt_affected_rows($stmt))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top