note 51057 added to function.odbc-exec

From: Date: Fri, 18 Mar 2005 12:54:37 +0000
Subject: note 51057 added to function.odbc-exec
Groups: php.notes 
Request: Send a blank email to php-notes+get-86617@lists.php.net to get a copy of this message
hi all, I managed to get this little snippet working, it's pretty useful if you have long forms to be inserted into a database. if ( ! empty ( $_POST ) ){ array_pop($_POST); foreach($_POST as $key => $val){ $columns .= addslashes($key) . ", "; $values .= "'" . addslashes($val) . "', "; } $values = substr_replace($values, "", -2); $columns = substr_replace($columns, "", -2); $sql = "INSERT INTO table ($columns) VALUES ($values)"; echo $sql; $results = odbc_exec($conn, $sql); if ($results){ echo "Query Executed"; }else { echo "Query failed " .odbc_error(); } } Not the most secure in the world but, speeds up collecting data from large forms. ---- Manual Page -- http://www.php.net/manual/en/function.odbc-exec.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51057 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51057&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51057&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51057&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51057&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51057&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51057&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#86617) next »