How to ‘insert if not exists’ in MySQL?

Written by leif. Posted in Mysql, PHP, Tips


there’s also INSERT … ON DUPLICATE KEY UPDATE syntax, you can find explanations on

Post from
18th October 2007

To start: as of the latest MySQL, syntax presented in the title is not possible. But there are several very easy ways to accomplish what is expected using existing functionality.

There are 3 possible solutions: using INSERT IGNORE, REPLACE, or INSERT … ON DUPLICATE KEY UPDATE.Imagine we have a table:

CREATE TABLE `transcripts` (

Compare two MySQL databases

Written by leif. Posted in Tips

If you’re working with small databases I’ve found running mysqldump on both databases with the --skip-comments and --skip-extended-insert options to generate SQL scripts, then running diff on the SQL scripts works pretty well.

By skipping comments you avoid meaningless differences such as the time you ran the mysqldump command. By using the --skip-extended-insert command you ensure each row is inserted with its


fpdf – tabel-cells example

Written by leif. Posted in PHP, Programmering


$pdf->Cell(40,5,'[ x ] checkbox1′,1,0,’L’,0);
$pdf->Cell(40,5,'[ x ] checkbox2′,1,0,’L’,0);
$pdf->Cell(40,5,'[ x ] checkbox3′,1,0,’L’,0);


$pdf->Cell(40,5,'[ x ] checkbox4′,1,0,’L’,0);
$pdf->Cell(40,5,'[ x ] checkbox5′,1,0,’L’,0);
$pdf->Cell(40,5,'[ x ] checkbox6′,1,0,’L’,0);


Word tips

Written by leif. Posted in Tips

Ctrl + F1: Vis eller fjern topfanen (Ribbon).
Ctrl + K: Indsæt et hyberlink på den markerede tekst.
Ctrl + F: Fed (dansk version) / Åben et søgefelt (engelsk version). Ctrl + B er søgefeltet på dansk.
Alt + Ctrl + 5: Split eller fjern split i et dokumentvindue.
Ctrl + Backspace: Slet ét ord mod venstre.
Shift + F3: ændre bogstavstørrelse (R –> r) på de markerede ord.


Check if service is running

Written by leif. Posted in Dos, Programmering

@echo off
sc query "%~1"|findstr "STATE.*:.*4.*RUNNING" >NUL
ECHO service %1 is stopped
goto :end
echo Service %1 is running

Call of Duty OU screen resolution

Written by leif. Posted in Game, Tips


seta cg_fov 96.4183
seta r_mode -1
seta r_customheight 1080
seta r_customwidth 1920

to the file \Call of Duty\uo\uoconfig_mp.cfg




Quake II server

Written by leif. Posted in Server, Tips

Quake II – Co-Op Dedicated Server Tutorial

I think this is the best way to create a Co-Op server.

  • Create a .bat file in your Quake II folder. Name it anything you like.
  • Edit the .bat file with WordPad. It should look like this:

@echo off
quake2.exe +set dedicated 1 +exec servercoop.cfg

  • Now go into your baseq2 folder. It’s in your Quake II folder.
  • Create a .cfg file. Name it “servercoop.cfg”.
  • Edit the .cfg file with WordPad. It should look like this:


CBT Soap Fault from VMWare when runnnig Veeam backup

Written by leif. Posted in Errors, Server, Tips

The error means that Veeam cannot identify what blocks have changed. This could have numerous causes, for example, your storage was powered down without to shut down the VMs via guest OS first.

The fix is fairly simple but it does require powercycling the VM, see KB:1113 – How to reset CBT. From the KB article:

  1. Power off the VM
  2. Right click the VM, click “Edit settings”, find the “Options” tab and click “Configuration Parameters”
  3. Set the “ctkEnabled” value to false
  4. Set the “scsi0:x.ctkEnabled” value to false for each disk of the VM in question5. Open the source folder and remove any -CTK.VMDK files.
  5. Power on the VM
  6. Power off the VM again. This step is needed to update the CTK table.
  7. Power on the VM
  8. Rerun Backup or Replication job to re-enable CBT