Skip to content

Instantly share code, notes, and snippets.

@jonashansen229
jonashansen229 / class.database.php
Last active June 20, 2023 08:41
PHP OOP Database class using MySQLI and Singleton pattern. Only one instance of the class will be made, this requires less memory.
<?php
/*
* Mysql database class - only one connection alowed
*/
class Database {
private $_connection;
private static $_instance; //The single instance
private $_host = "HOSTt";
private $_username = "USERNAME";
private $_password = "PASSWORd";
@jonashansen229
jonashansen229 / html5test.html
Last active November 10, 2021 13:52
HTML5 - required fields, placeholders, types, pattern and datalist
<!DOCTYPE html>
<head>
<title>HTML5 TryOut</title>
<meta charset="UTF-8">
</head>
<body>
<form autocomplete="on">
*First Name: <input placeholder="First name" name="fname" type="text" required /> <br />
*Last name: <input type="text" name="lname" placeholder="Last name" /><br />
Telephone: <input type="tel" name="phone" /> <br/>
@jonashansen229
jonashansen229 / PHPOOP-databaseclass-mysqli.php
Last active April 21, 2021 10:26
php mysqli database class
<?php
class Database {
protected $_link;
protected $_result;
protected $_numRows;
private $_host = "HOST";
private $_username = "DATABASE USERNAME";
private $_password = "DATABASE PASSWORD";
private $_database = "DATABASE";
public function charFix($text) {
return mb_convert_encoding($text,"HTML-ENTITIES","UTF-8");
}
@jonashansen229
jonashansen229 / zipFilesFunction.php
Created January 24, 2013 17:41
Function that zip's a directory. Including all files and sub-directories. @param string dirname(name of target dir), @param object zip (object of ZipArchive)
<?php
public function zipFiles($dirName, $zip) {
$zipName = $dirName.'.zip';
$filenames = array();
$path = $this->_uploadFolder.$dirName.'/';
ini_set('max_execution_time', 5000);
// Opening and creating zip file
if($zip->open($path.$zipName, $overwrite ? ZIPARCHIVE::OVERWRITE :
ZIPARCHIVE::CREATE) !== true) {