<?php
require_once('config.php');

function insert_error_log($site_cd, $error, $audit_user, $module, $action){
	global $conn;
	
	$sql_insert_log_err = "	INSERT Into log_err (	site_cd,				log_err_login,			log_err_desc,		log_err_date,
													column1, 				column2,				column3,			column4,			column5)					
							 VALUES 			(	?,						?,						?,					getdate(),
													?,						?,						?,					?,					?)" ;

	$params_insert_log_err = array(					$site_cd,				$audit_user,			$error,									$audit_user,			
													$module,				$action,				NUll,				NUll,				NUll);
									
									
	//echo 	$params_insert_eml_log;							
	$stmt_insert_log_err = sqlsrv_query( $conn, $sql_insert_log_err, $params_insert_log_err);	
	
	if( !$stmt_insert_log_err ) {
		$error_message = "Error (INSERT Table log_err)";	
if (($errors = sqlsrv_errors()) != null){
			foreach ($errors as $error)	{
				echo $error['message'];
				//file_put_contents($file_name, $now . "\r\n" . $sql_wo_detail . "\r\n" . "SQLSTATE: " . $error['SQLSTATE'] . "\r\n" . "code: " . $error['code'] . "\r\n" . "message: " . $error['message'] . "\r\n\r\n", FILE_APPEND);
				
			}
		}
	}
	sqlsrv_free_stmt( $stmt_insert_log_err);

	return true;
}


?>