I'm making a blog site and I need to check if a tag exists before inserting the tag into the tblTag

This is what I'm trying:

```
 $var_sqlTagsCheck = "IF (EXISTS(SELECT * FROM tblTag t WHERE t.tagName = '$var_tagCollectInsert'))
 BEGIN
    INSERT IGNORE INTO tblTag
 SET tagName = '$var_tagCollectInsert'
 END
 ELSE
 BEGIN
 INSERT INTO tblTag (tagId, tagName) VALUES ('', '$var_tagCollectInsert'))
 END
 ";

```

But is not working correctly, can anybody lend me some assistance here?? Where am i going wrong, this seems fairly straight forward SQL.