note 12054 added to function.mysql-query.php
| From: | someone at somewhere dot in dot net | Date: | Tue, 20 Mar 2001 18:05:51 +0000 |
| Subject: | note 12054 added to function.mysql-query.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-12586@lists.php.net to get a copy of this message | ||
thought it may help someone ..
function runSQL( $sql, $mysql) {
// execs a query and returns
// the number of rows returned or affected.
// -1 if error occured
global $isOK, $errorMsg, $result;
$isOK = -1; $errorMsg = "";
$sql = ltrim( $sql );
$sqlType = strtoupper( substr( $sql , 0, strpos( $sql, ' ', 0)));
$result = mysql_query( $sql, $mysql );
$errorMsg = mysql_error();
if ( $errorMsg == "" ) {
if ( $sqlType == "SELECT" ) {
$isOK = mysql_num_rows( $result );
} else {
$isOK = mysql_affected_rows();
}
}
return $isOK;
}
http://www.php.net/manual/en/function.mysql-query.php