Archive for November 2019

Simple php based mysql query script

<?php   $dbname = ‘dbname’; $dbuser = ‘user’; $dbpass = ‘pass’; $dbhost = ‘hostname’;   $connect = mysql_connect($dbhost, $dbuser, $dbpass) or die("Unable to Connect to ‘$dbhost’"); mysql_select_db($dbname) or die("Could not open the db ‘$dbname’"); $test_query = "SELECT 1,2,3,4 FROM yourtable"; $result = mysql_query($test_query); $tblCnt = 0; while($tbl = mysql_fetch_array($result)) { $tblCnt++; echo $tbl[0]."<br />\n"; echo […]

How-to detach running process from terminal

If your job is running in terminal do bg — Move running process to background — jobs — list the jobs in background and get id of the job you want to detach — disown %1 — use job id from previous query for detaching from the terminal —

Mysql show full list of processes in memory

SHOW FULL PROCESSLIST;

Php Nearest Match

function getNearestMatch($number, $candidates) {   $candidates = is_array($candidates) ? $candidates : array($candidates);   $size = count($candidates); if ($size > 0) { //absolute difference between 0th element and input value $diff = abs($candidates[0] – $number); //element closest to input value $ret = $candidates[0]; //loop through the rest of the array for ($i = 1; $i < […]