note 12054 deleted from function.mysql-query by jimw
| From: | jimw@php.net | Date: | Sat, 08 Dec 2001 22:15:52 +0000 |
| Subject: | note 12054 deleted from function.mysql-query by jimw | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-22288@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;
}