Snippets v2

Languages
My Snippets

AutoExecute UPDATE with ADODB Login or Register to Bookmark this snippet

Description PHP

An alternative way of updating a table using ADODB, utilising the AutoExecute function. Makes the code a bit tidier.

The Code Download
  1. <?php
  2. $record['lot_number']   = $_POST['lot_number'];
  3. $record['name']         = stripslashes($_POST['name']);
  4. $record['description']  = stripslashes($_POST['description']);
  5. $update_id = 'animal_id = ' . $_POST['animal_id'];
  6.  
  7. $result = $db->AutoExecute('table_name', $record, 'UPDATE', $update_id);
  8. if ($result === false) {
  9.     echo 'Error updating: '.$db->ErrorMsg();
  10. } else {
  11.     echo = 'Animal updated';
  12. }
  13. ?>
Credits Contact JC

Added by JC on 14th November, 2007

Comments

There are no comments about this snippet.

Post Comment HTML is allowed

You must be registered and logged in to post a comment.

Login here to post a comment