PHP Date Format

A common mistake that i always do is to forget the strtotime field

Here is where i usually use it.

Enjoy

Coffee Cup


***************************************************

	//20221117
	if ($pldate != '')
	{
		$pldate = date("m/d/Y", strtotime($pldate));
	}
	
	if ($plcheck_date != '')
	{
		$plcheck_date = date("m/d/Y", strtotime($plcheck_date));	
	}
				
?>	
        <div id="page-wrapper">

***************************************************

$pltype = $_POST['pltype'];
$pltype = htmlspecialchars( $pltype, ENT_QUOTES);

	//20160904
	if ($pldate != '')
	{
		$pldate = date("Y-m-d", strtotime($pldate));
	}
	
	if ($plcheck_date != '')
	{
		$plcheck_date = date("Y-m-d", strtotime($plcheck_date));	
		$plcheck_date2 = date("Y-m-d", strtotime($plcheck_date));	
	}
	else
	{
		$plcheck_date2 = NULL;	
	}

***************************************************


Delphi Get Sales Summary by Month (January to December)

Another feature i hope there was shortcut to, but it seems i need to write it myself.

Just wanted to share it here

Coffee Cup


    VFROM = VYEAR || '-1-1';
    VTO = VYEAR || '-1-31';

    SELECT SUM(Z.PAMT)
    FROM  PAYSLIP Z
    WHERE Z.PDATE_COMPUTE_FROM >= :VFROM AND Z.PDATE_COMPUTE_TO <= :VTO AND Z.EID = :VEID
    INTO :VAMT;  

    IF (VAMT IS NULL) THEN
         PAMT1 = 0;
    ELSE PAMT1 = VAMT;  

    /* /////////////////////////////// */



    /* IF FEB LESS THAN MARCH 1 - THERE IS FEB 28 AND FEB 29 */
    VFROM = VYEAR || '-2-1';
    VTO = VYEAR || '-3-1';

    SELECT SUM(Z.PAMT)
    FROM  PAYSLIP Z
    WHERE Z.PDATE_COMPUTE_FROM >= :VFROM AND Z.PDATE_COMPUTE_TO < :VTO AND Z.EID = :VEID
    INTO :VAMT;  

    IF (VAMT IS NULL) THEN
         PAMT2 = 0;
    ELSE PAMT2 = VAMT;  

    /* /////////////////////////////// */



    VFROM = VYEAR || '-3-1';
    VTO = VYEAR || '-3-31';

    SELECT SUM(Z.PAMT)
    FROM  PAYSLIP Z
    WHERE Z.PDATE_COMPUTE_FROM >= :VFROM AND Z.PDATE_COMPUTE_TO <= :VTO AND Z.EID = :VEID
    INTO :VAMT;  

    IF (VAMT IS NULL) THEN
         PAMT3 = 0;
    ELSE PAMT3 = VAMT;  

    /* /////////////////////////////// */



    VFROM = VYEAR || '-4-1';
    VTO = VYEAR || '-4-30';

    SELECT SUM(Z.PAMT)
    FROM  PAYSLIP Z
    WHERE Z.PDATE_COMPUTE_FROM >= :VFROM AND Z.PDATE_COMPUTE_TO <= :VTO AND Z.EID = :VEID
    INTO :VAMT;  

    IF (VAMT IS NULL) THEN
         PAMT4 = 0;
    ELSE PAMT4 = VAMT;  

    /* /////////////////////////////// */



    VFROM = VYEAR || '-5-1';
    VTO = VYEAR || '-5-31';

    SELECT SUM(Z.PAMT)
    FROM  PAYSLIP Z
    WHERE Z.PDATE_COMPUTE_FROM >= :VFROM AND Z.PDATE_COMPUTE_TO <= :VTO AND Z.EID = :VEID
    INTO :VAMT;  

    IF (VAMT IS NULL) THEN
         PAMT5 = 0;
    ELSE PAMT5 = VAMT;  

    /* /////////////////////////////// */



    VFROM = VYEAR || '-6-1';
    VTO = VYEAR || '-6-30';

    SELECT SUM(Z.PAMT)
    FROM  PAYSLIP Z
    WHERE Z.PDATE_COMPUTE_FROM >= :VFROM AND Z.PDATE_COMPUTE_TO <= :VTO AND Z.EID = :VEID
    INTO :VAMT;  

    IF (VAMT IS NULL) THEN
         PAMT6 = 0;
    ELSE PAMT6 = VAMT;  

    /* /////////////////////////////// */



    VFROM = VYEAR || '-7-1';
    VTO = VYEAR || '-7-31';

    SELECT SUM(Z.PAMT)
    FROM  PAYSLIP Z
    WHERE Z.PDATE_COMPUTE_FROM >= :VFROM AND Z.PDATE_COMPUTE_TO <= :VTO AND Z.EID = :VEID
    INTO :VAMT;  

    IF (VAMT IS NULL) THEN
         PAMT7 = 0;
    ELSE PAMT7 = VAMT;  

    /* /////////////////////////////// */



    VFROM = VYEAR || '-8-1';
    VTO = VYEAR || '-8-31';

    SELECT SUM(Z.PAMT)
    FROM  PAYSLIP Z
    WHERE Z.PDATE_COMPUTE_FROM >= :VFROM AND Z.PDATE_COMPUTE_TO <= :VTO AND Z.EID = :VEID
    INTO :VAMT;  

    IF (VAMT IS NULL) THEN
         PAMT8 = 0;
    ELSE PAMT8 = VAMT;  

    /* /////////////////////////////// */



    VFROM = VYEAR || '-9-1';
    VTO = VYEAR || '-9-30';

    SELECT SUM(Z.PAMT)
    FROM  PAYSLIP Z
    WHERE Z.PDATE_COMPUTE_FROM >= :VFROM AND Z.PDATE_COMPUTE_TO <= :VTO AND Z.EID = :VEID
    INTO :VAMT;  

    IF (VAMT IS NULL) THEN
         PAMT9 = 0;
    ELSE PAMT9 = VAMT;  

    /* /////////////////////////////// */



    VFROM = VYEAR || '-10-1';
    VTO = VYEAR || '-10-31';

    SELECT SUM(Z.PAMT)
    FROM  PAYSLIP Z
    WHERE Z.PDATE_COMPUTE_FROM >= :VFROM AND Z.PDATE_COMPUTE_TO <= :VTO AND Z.EID = :VEID
    INTO :VAMT;  

    IF (VAMT IS NULL) THEN
         PAMT10 = 0;
    ELSE PAMT10 = VAMT;  

    /* /////////////////////////////// */



    VFROM = VYEAR || '-11-1';
    VTO = VYEAR || '-11-30';

    SELECT SUM(Z.PAMT)
    FROM  PAYSLIP Z
    WHERE Z.PDATE_COMPUTE_FROM >= :VFROM AND Z.PDATE_COMPUTE_TO <= :VTO AND Z.EID = :VEID
    INTO :VAMT;  

    IF (VAMT IS NULL) THEN
         PAMT11 = 0;
    ELSE PAMT11 = VAMT;  

    /* /////////////////////////////// */



    VFROM = VYEAR || '-12-1';
    VTO = VYEAR || '-12-31';

    SELECT SUM(Z.PAMT)
    FROM  PAYSLIP Z
    WHERE Z.PDATE_COMPUTE_FROM >= :VFROM AND Z.PDATE_COMPUTE_TO <= :VTO AND Z.EID = :VEID
    INTO :VAMT;  

    IF (VAMT IS NULL) THEN
         PAMT12 = 0;
    ELSE PAMT12 = VAMT;  

    /* /////////////////////////////// */

Delphi Code to get the Next 6 months

This code is what i use to get the 6 months of the month. Including the parameter of February where we sometimes have a 28th or 29th day.

Just in case this code helps you, please drop us a line

Coffee Cup




   /* 2-16-2023 - CREATE SUMMARY */

  VYEAR = EXTRACT(YEAR FROM VDATEFROM);
  VMONTH = EXTRACT(MONTH FROM VDATEFROM);

  SAFROM1 = VYEAR || '-' || VMONTH || '-1';
  IF (VMONTH = 12) THEN
  BEGIN
    VMONTH = 1;
    VYEAR =  VYEAR + 1;
    SATO1 = VYEAR || '-' || VMONTH || '-1';
  END
  ELSE 
  BEGIN 
    VMONTH = VMONTH + 1;
    SATO1 = VYEAR || '-' || VMONTH || '-1';
  END
  SATO1 = SATO1 - 1;
  SAMONTH1 = 0;


  VDATE = SATO1 + 1;
  VYEAR = EXTRACT(YEAR FROM VDATE);
  VMONTH = EXTRACT(MONTH FROM VDATE);

  SAFROM2 = VYEAR || '-' || VMONTH || '-1';
  IF (VMONTH = 12) THEN
  BEGIN
    VMONTH = 1;
    VYEAR =  VYEAR + 1;
    SATO2 = VYEAR || '-' || VMONTH || '-1';
  END
  ELSE 
  BEGIN 
    VMONTH = VMONTH + 1;
    SATO2 = VYEAR || '-' || VMONTH || '-1';
  END
  SATO2 = SATO2 - 1;
  SAMONTH2 = 0;



  VDATE = SATO2 + 1;
  VYEAR = EXTRACT(YEAR FROM VDATE);
  VMONTH = EXTRACT(MONTH FROM VDATE);

  SAFROM3 = VYEAR || '-' || VMONTH || '-1';
  IF (VMONTH = 12) THEN
  BEGIN
    VMONTH = 1;
    VYEAR =  VYEAR + 1;
    SATO3 = VYEAR || '-' || VMONTH || '-1';
  END
  ELSE 
  BEGIN 
    VMONTH = VMONTH + 1;
    SATO3 = VYEAR || '-' || VMONTH || '-1';
  END
  SATO3 = SATO3 - 1;
  SAMONTH3 = 0;



  VDATE = SATO3 + 1;
  VYEAR = EXTRACT(YEAR FROM VDATE);
  VMONTH = EXTRACT(MONTH FROM VDATE);

  SAFROM4 = VYEAR || '-' || VMONTH || '-1';
  IF (VMONTH = 12) THEN
  BEGIN
    VMONTH = 1;
    VYEAR =  VYEAR + 1;
    SATO4 = VYEAR || '-' || VMONTH || '-1';
  END
  ELSE 
  BEGIN 
    VMONTH = VMONTH + 1;
    SATO4 = VYEAR || '-' || VMONTH || '-1';
  END
  SATO4 = SATO4 - 1;
  SAMONTH4 = 0;




  VDATE = SATO4 + 1;
  VYEAR = EXTRACT(YEAR FROM VDATE);
  VMONTH = EXTRACT(MONTH FROM VDATE);

  SAFROM5 = VYEAR || '-' || VMONTH || '-1';
  IF (VMONTH = 12) THEN
  BEGIN
    VMONTH = 1;
    VYEAR =  VYEAR + 1;
    SATO5 = VYEAR || '-' || VMONTH || '-1';
  END
  ELSE 
  BEGIN 
    VMONTH = VMONTH + 1;
    SATO5 = VYEAR || '-' || VMONTH || '-1';
  END
  SATO5 = SATO5 - 1;
  SAMONTH5 = 0;



  VDATE = SATO5 + 1;
  VYEAR = EXTRACT(YEAR FROM VDATE);
  VMONTH = EXTRACT(MONTH FROM VDATE);

  SAFROM6 = VYEAR || '-' || VMONTH || '-1';
  IF (VMONTH = 12) THEN
  BEGIN
    VMONTH = 1;
    VYEAR =  VYEAR + 1;
    SATO6 = VYEAR || '-' || VMONTH || '-1';
  END
  ELSE 
  BEGIN 
    VMONTH = VMONTH + 1;
    SATO6 = VYEAR || '-' || VMONTH || '-1';
  END
  SATO6 = SATO6 - 1;
  SAMONTH6 = 0;

  SAOTHERS = 0;
  SAUNPAID = 0;

  SUSPEND;

   /* 2-16-2023 - CREATE SUMMARY */
















    /* 2-16-2023 - CREATE SUMMARY */
    VDATE = NULL;
    IF (OCCHECK_DATE IS NOT NULL) THEN
    BEGIN
      VDATE = OCCHECK_DATE;
    END
    IF (OMDATE IS NOT NULL) THEN
    BEGIN
      VDATE = OMDATE;
    END

    IF (VDATE IS NOT NULL) THEN
    BEGIN
      IF ((VDATE >= SAFROM1) AND (VDATE <= SATO1)) THEN
        SAMONTH1 = SAMONTH1 + CP_INVAMT;
      ELSE
      IF ((VDATE >= SAFROM2) AND (VDATE <= SATO2)) THEN
        SAMONTH2 = SAMONTH2 + CP_INVAMT;
      ELSE
      IF ((VDATE >= SAFROM3) AND (VDATE <= SATO3)) THEN
        SAMONTH3 = SAMONTH3 + CP_INVAMT;
      ELSE
      IF ((VDATE >= SAFROM4) AND (VDATE <= SATO4)) THEN
        SAMONTH4 = SAMONTH4 + CP_INVAMT;
      ELSE
      IF ((VDATE >= SAFROM5) AND (VDATE <= SATO5)) THEN
        SAMONTH5 = SAMONTH5 + CP_INVAMT;
      ELSE
      IF ((VDATE >= SAFROM6) AND (VDATE <= SATO6)) THEN
        SAMONTH6 = SAMONTH6 + CP_INVAMT;
      ELSE
        SAOTHERS = SAOTHERS + CP_INVAMT;
    END

Delphi + Excel OLE Manipulation (Change Font, Masking and More)

Delphi + Excel OLE

Thought of saving this one here. For those who still use delphi in 2023, here are the features you can access. Just in case you have questions or issues encountered, just drop me a line

Coffee Cup

...control Excel with OLE?
Autor: Thomas Stutz
[ Print tip ]	 	 

Tip Rating (503):	 
     

uses
  ComObj;

var
  ExcelApp: OleVariant;

implementation


procedure TForm1.Button1Click(Sender: TObject);
const
  // SheetType
  xlChart = -4109;
  xlWorksheet = -4167;
  // WBATemplate
  xlWBATWorksheet = -4167;
  xlWBATChart = -4109;
  // Page Setup
  xlPortrait = 1;
  xlLandscape = 2;
  xlPaperA4 = 9;
  // Format Cells
  xlBottom = -4107;
  xlLeft = -4131;
  xlRight = -4152;
  xlTop = -4160;
  // Text Alignment
  xlHAlignCenter = -4108;
  xlVAlignCenter = -4108;
  // Cell Borders
  xlThick = 4;
  xlThin = 2;
var
  ColumnRange: OleVariant;

  // Function to get the number of Rows in a Certain column

  function GetLastLine(AColumn: Integer): Integer;
  const
    xlUp = 3;
  begin
    Result := ExcelApp.Range[Char(96 + AColumn) + IntToStr(65536)].end[xlUp].Rows.Row;
  end;

begin
  { Start Excel }

  // By using GetActiveOleObject, you use an instance of Word that's already running,
  // if there is one.
  try
    ExcelApp := GetActiveOleObject('Excel.Application');
  except
    try
      // If no instance of Word is running, try to Create a new Excel Object
      ExcelApp := CreateOleObject('Excel.Application');
    except
      ShowMessage('Cannot start Excel/Excel not installed ?');
      Exit;
    end;
  end;

  // Add a new Workbook, Neue Arbeitsmappe ?ffnen
  ExcelApp.Workbooks.Add(xlWBatWorkSheet);

  // Open a Workbook, Arbeitsmappe ?ffnen
  ExcelApp.Workbooks.Open('c:\YourFileName.xls');


  // Rename the active Sheet
  ExcelApp.ActiveSheet.Name := 'This is Sheet 1';

  // Rename
  ExcelApp.Workbooks[1].WorkSheets[1].Name := 'This is Sheet 1';

  // Insert some Text in some Cells[Row,Col]
  ExcelApp.Cells[1, 1].Value := 'SwissDelphiCenter.ch';
  ExcelApp.Cells[2, 1].Value := 'http://www.swissdelphicenter.ch';
  ExcelApp.Cells[3, 1].Value := FormatDateTime('dd-mmm-yyyy', Now);

  // Setting a row of data with one call
  ExcelApp.Range['A2', 'D2'].Value := VarArrayOf([1, 10, 100, 1000]);

  // Setting a formula
  ExcelApp.Range['A11', 'A11'].Formula := '=Sum(A1:A10)';

  // Change Cell Alignement
  ExcelApp.Cells[2, 1].HorizontalAlignment := xlright;

  // Change the Column Width.
  ColumnRange := ExcelApp.Workbooks[1].WorkSheets[1].Columns;
  ColumnRange.Columns[1].ColumnWidth := 20;
  ColumnRange.Columns[2].ColumnWidth := 40;

  // Change Rowheight / Zeilenh?he ?ndern:
  ExcelApp.Rows[1].RowHeight := 15.75;

  // Merge cells, Zellen verbinden:
  ExcelApp.Range['B3:D3'].Mergecells := True;

  // Apply borders to cells, Zellen umrahmen:
  ExcelApp.Range['A14:M14'].Borders.Weight := xlThick; // Think line/ Dicke Linie
  ExcelApp.Range['A14:M14'].Borders.Weight := xlThin;  // Thin line D邦nne Linie

  // Set Bold Font in cells, Fettdruck in den Zellen

  ExcelApp.Range['B16:M26'].Font.Bold := True;

  // Set Font Size, Schriftgr??e setzen
  ExcelApp.Range['B16:M26'].Font.Size := 12;

  //right-aligned Text, rechtsb邦ndige Textausrichtung
  ExcelApp.Cells[9, 6].HorizontalAlignment := xlright;

  // horizontal-aligned text, horizontale Zentrierung
  ExcelApp.Range['B14:M26'].HorizontalAlignment := xlHAlignCenter;

  // left-aligned Text, vertikale Zentrierung
  ExcelApp.Range['B14:M26'].VerticallyAlignment := xlVAlignCenter;


  { Page Setup }

  ExcelApp.ActiveSheet.PageSetup.Orientation := xlLandscape;

  // Left, Right Margin (Seitenr?nder)
  ExcelApp.ActiveSheet.PageSetup.LeftMargin  := 35;
  ExcelApp.ActiveSheet.PageSetup.RightMargin := -15;

  // Set Footer Margin
  ExcelApp.ActiveSheet.PageSetup.FooterMargin := ExcelApp.InchesToPoints(0);

  // Fit to X page(s) wide by Y tall
  ExcelApp.ActiveSheet.PageSetup.FitToPagesWide := 1;  // Y
  ExcelApp.ActiveSheet.PageSetup.FitToPagesTall := 3; // Y

  // Zoom
  ExcelApp.ActiveSheet.PageSetup.Zoom := 95;

  // Set Paper Size:
  ExcelApp.PageSetup.PaperSize := xlPaperA4;

  // Show/Hide Gridlines:
  ExcelApp.ActiveWindow.DisplayGridlines := False;

  // Set Black & White
  ExcelApp.ActiveSheet.PageSetup.BlackAndWhite := False;

  // footers
  ExcelApp.ActiveSheet.PageSetup.RightFooter := 'Right Footer / Rechte Fu?zeile';
  ExcelApp.ActiveSheet.PageSetup.LeftFooter  := 'Left Footer / Linke Fu?zeile';

  // Show Excel Version:
  ShowMessage(Format('Excel Version %s: ', [ExcelApp.Version]));

  // Show Excel:
  ExcelApp.Visible := True;

  // Save the Workbook
  ExcelApp.SaveAs('c:\filename.xls');

  // Save the active Workbook:
  ExcelApp.ActiveWorkBook.SaveAs('c:\filename.xls');

end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  // Quit Excel
  if not VarIsEmpty(ExcelApp) then
  begin
    ExcelApp.DisplayAlerts := False;  // Discard unsaved files....
    ExcelApp.Quit;
  end;
end;

Contact Us – How to send email with attachment in PHP

Send Email Attachment

I have done a lot of contact us page in websites before and this one, i had to add email attachments as well. The secret to it was to upload it to your website before you can send it as an email attachment.

Recently I found a great website that does that.

Hope it helps somebody out there

Coffee Cup

<?php 
 
// Recipient 
$to = '[email protected]'; 
 
// Sender 
$from = '[email protected]'; 
$fromName = 'CodexWorld'; 
 
// Email subject 
$subject = 'PHP Email with Attachment by CodexWorld';  
 
// Attachment file 
$file = "files/codexworld.pdf"; 
 
// Email body content 
$htmlContent = ' 
    <h3>PHP Email with Attachment by CodexWorld</h3> 
    <p>This email is sent from the PHP script with attachment.</p> 
'; 
 
// Header for sender info 
$headers = "From: $fromName"." <".$from.">"; 
 
// Boundary  
$semi_rand = md5(time());  
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";  
 
// Headers for attachment  
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; 
 
// Multipart boundary  
$message = "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"UTF-8\"\n" . 
"Content-Transfer-Encoding: 7bit\n\n" . $htmlContent . "\n\n";  
 
// Preparing attachment 
if(!empty($file) > 0){ 
    if(is_file($file)){ 
        $message .= "--{$mime_boundary}\n"; 
        $fp =    @fopen($file,"rb"); 
        $data =  @fread($fp,filesize($file)); 
 
        @fclose($fp); 
        $data = chunk_split(base64_encode($data)); 
        $message .= "Content-Type: application/octet-stream; name=\"".basename($file)."\"\n" .  
        "Content-Description: ".basename($file)."\n" . 
        "Content-Disposition: attachment;\n" . " filename=\"".basename($file)."\"; size=".filesize($file).";\n" .  
        "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n"; 
    } 
} 
$message .= "--{$mime_boundary}--"; 
$returnpath = "-f" . $from; 
 
// Send email 
$mail = @mail($to, $subject, $message, $headers, $returnpath);  
 
// Email sending status 
echo $mail?"<h1>Email Sent Successfully!</h1>":"<h1>Email sending failed.</h1>"; 
 
?>

How to Fix Windows 10 “Cannot Connect to Printer” – Error 0x0000011b

How to Fix Windows Cannot Connect to Printer

I have a case that a newly installed windows 10 pc, although already shared the 2 printers, the pc on the network cannot establish share.

The system says ‘Connect to Printer’ error.

What you can do is to go to registry editor,

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print

right click and create new DWORD 32 Bit

RpcAuthnLevelPrivacyEnabled

right click and click Modify. it should be hexadecimal with 0

Next is to open the windows services and look for PrinterSpool

Then right click and then click RESTART

After that, you can now use File Explorer to add the printer remote thru the network.

Hope it helps

Coffee Cup

Microsoft SQL Server Eating Lots of Hard Drive

Microsoft SQL Server Dump Files

I had a case recently about their server that have zero 0 space remaining in their drive C. i have seen this issue before and it involves the dump files collected every time the server is restarted.

The path to the dump files can be “C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Log\Polybase\dump”

Another path is “X:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\Log”

Recently i have searched if there was a way to turn it off

Some have version folders

VersionPath
SQL Server 2019C:\Windows\SysWOW64\SQLServerManager15.msc
SQL Server 2017C:\Windows\SysWOW64\SQLServerManager14.msc
SQL Server 2016C:\Windows\SysWOW64\SQLServerManager13.msc
SQL Server 2014C:\Windows\SysWOW64\SQLServerManager12.msc
SQL Server 2012C:\Windows\SysWOW64\SQLServerManager11.msc

net start “SQL Server (MSSQLSERVER)”

next i found is the data collector

USE msdb; GO EXEC dbo.sp_syscollector_disable_collector;

Hope this info help out a fellow traveller

Coffee Cup

GFIX — Firebird Administration

GFIX is Firebird’s command line tool for administration issues like data repair, sweeping, etc.

General Syntax

gfix [options] -user <username> -password <password> <database> [options]
 
-user <username>Database user name
-pas[sword] <password>Database password
-fet[ch_password] <filename>Instead of -password: Fetch password from the file so it is not visible in the command line. When <filename> is stdin, the user will be prompted for the password. [Firebird 2.5]

Database Shutdown

When a database has been shut down, only SYSDBA and the database owner are able to connect to the database in order to perform administrative tasks.

Options

-at[tach] <seconds>Used with the -shut option. Waits <seconds> seconds for all current connections to end. If after <seconds> seconds there are still connections open, the shutdown will be cancelled and return an error.
-f[orce] <seconds>Used with the -shut option. Waits <seconds> seconds for all connections and transactions to end. After this time, all connections and transactions are cancelled and the database is shut down. Use with caution.
-o[nline]If a -shut operation is pending, it is cancelled. Otherwise, takes a database back online
-sh[ut]Shut down database. Must be used together with -attach, -force or -tran
-shut {normal | multi | single | full}-online {normal | multi | single | full} Firebird 2.0 and later: New shutdown modes:NORMAL: Database is active and online
MULTI: Only connection from SYSDBA and the Database Owner will be allowed (compatible mode with Firebird 1.0/1.5)
SINGLE: Only one SYSDBA or Database Owner connection will be allowed
FULL: Exclusive shutdown: Database is completely offline, no connections will be allowed (it is now possible to access the database file safely on a file basis, e.g. for backups)Use -shut to “go down” the scale of shutting down and -online to “go up” that scale.
-tr[an] <seconds>Used with the -shut option. Waits <seconds> seconds for all running transactions to end. If after <seconds> seconds there are still running transactions, the shutdown will be cancelled.

Examples

Shut down database, wait 60 seconds until all connections are closed

gfix -user SYSDBA -password "masterkey" dbserver:/db/mydb.fdb -shut -attach 60

Note that GFIX will terminate with an error if there are still connections open after 60 seconds.

Shut down database, force shutdown after 60 seconds

gfix -user SYSDBA -password masterkey dbserver:/db/mydb.fdb -shut -force 60

Shut down database, force shutdown NOW

gfix -user SYSDBA -password masterkey dbserver:/db/mydb.fdb -shut -force 0

Put database online again

gfix -user SYSDBA -password masterkey dbserver:/db/mydb.fdb -online

Examples for Firebird 2.0

Shut down database to single user mode

gfix -user SYSDBA -password masterkey dbserver:/db/mydb.fdb -shut single -force 60

Put database online again

gfix -user SYSDBA -password masterkey dbserver:/db/mydb.fdb -online normal

Shut down database, force shutdown NOW, allow no subsequent connections, even from SYSDBA or Owner

gfix -user SYSDBA -password masterkey dbserver:/db/mydb.fdb -shut full -force 0

Database Repair, Sweeping

Options

-f[ull]Use with the -v option. Checks all records and pages and releases unassigned record fragments
-h[ousekeeping] 0Switch off automatic sweeping
-h[ousekeeping] <n>Set Sweep Interval to <n> transactions (default is 20000)
-i[gnore]Ignores checksum errors during a validate or sweep
-m[end]Marks corrupt records as unavailable so they are skipped on a subsequent backup
-n[o_update]Use with the -v option. Checks all records and pages and reports errors but does not repair them
-sweepForces an immediate sweep
-v[alidate]Check database for validity. At the same time, errors are reported and repaired

Examples

Validate Database

gfix -user SYSDBA -password masterkey dbserver:/db/mydb.fdb -v -f

Sweep Database now

gfix -user SYSDBA -password masterkey dbserver:/db/mydb.fdb -sweep

Set Sweep Interval to 50000 transactions

gfix -user SYSDBA -password masterkey dbserver:/db/mydb.fdb -h 50000

Switch off Automatic Sweeping

gfix -user SYSDBA -password masterkey dbserver:/db/mydb.fdb -h 0

Misc

Options

-a[ctivate]Activate Shadow file for database usage
-b[uffers] <pages>Default cache buffers for the database will be set to <pages> pages
-c[ommit] <id>Commits limbo transaction specified by the given <id>
-c[ommit] allCommits all limbo transactions
-l[ist]Display IDs of all limbo transactions and what would happen to each transaction if you would use -t on it
-mo[de] read_writeSet mode of database to read/write (default). Requires exclusive access to database (shutdown)
-mo[de] read_onlySet mode of database to read-only. Requires exclusive access to database (shutdown)
-pa[ssword] <password>Database password
-p[rompt]Use with -l. Prompts for action.
-r[ollback] <id>Rolls back limbo transaction specified by the given <id>
-r[ollback] allRolls back all limbo transactions
-s[ql_dialect] 1Sets SQL dialect 1 for the database
-s[ql_dialect] 3Sets SQL dialect 3 for the database
-t[wo_phase] <id>Performs automated two-phase recovery for limbo transaction with the given <id>
-t[wo_phase] allPerforms automated two-phase recovery for all limbo transactions
-user <name>Database username
-w[rite] syncEnables Forced Writes
-w[rite] asyncDisabled Forced Writes
-zShow GFIX and server version

Examples

Set Database to Read-Only

gfix -user SYSDBA -password masterkey dbserver:/db/mydb.fdb -shut -attach 60
gfix -user SYSDBA -password masterkey dbserver:/db/mydb.fdb -shut -force 0
gfix -user SYSDBA -password masterkey dbserver:/db/mydb.fdb -mode read_only
gfix -user SYSDBA -password masterkey dbserver:/db/mydb.fdb -online

Set Database to SQL Dialect 3

gfix -user SYSDBA -password masterkey dbserver:/db/mydb.fdb -sql_dialect 3

Enable Forced Writes

gfix -user SYSDBA -password masterkey dbserver:/db/mydb.fdb -write sync

Disable Forced Writes

gfix -user SYSDBA -password masterkey dbserver:/db/mydb.fdb -write async

http://www.destructor.de/firebird/gfix.htm

Win10 Cannot Connect to Shared Printer

Recently i encountered a problem that doesn’t allow me to add a shared printer. It seems to be new so it might have something to do with the windows update.

Then i found the solutions. Its to add a registry entry. here it is :

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print\RpcAuthnLevelPrivacyEnabled to 0

Once you do this you can now continue.

Enjoy,

Coffee Cup