follow me, I know a shortcut Blog

Store images in MySQL 0

Store images in MySQL

Step 1. Setting up the database CREATE TABLE `images` ( id int NOT NULL AUTO_INCREMENT PRIMARY KEY, image_source BLOB ) Step 2. Upload script [php] if($picture != "none") { $pic_size = filesize($picture); $pic_source = addslashes(fread(fopen($picture, "r"), $pic_size)); mysql_connect($host,$username,$password) or die("Unable to connect to SQL server"); @mysql_select_db($db) or die("Unable to select database"); mysql_query("INSERT INTO `images` SET `image` = $pic_source"); } else { echo "No image uploaded.";...

Protect your work 0

Protect your work

Small script to protect you work. First, define a function check_license() [php] function check_license() { $license = ‘<a href="#">your links</a>’; $footer_file = ‘/path/to/footer-file.php’; $open_file = fopen($footer_file,’r’); $content = fread($open_file,filesize($footer_file)); fclose($open_file ); if(strpos($content, $license)==0) {die("Y u no work?");} } [/php] Then, call your function in template/header.

Display MySQL data in a multiple columns 0

Display MySQL data in a multiple columns

This is a small guide about how to extract data from a MySQL database and display in a multiple columns [php] $i=0; $members = mysql_query("SELECT * from `members`"); echo ‘<table> <tbody> <tr>’; while ($row = mysql_fetch_row($members)) { $i++; if ($i % 5 == 0) { echo ‘<td>’.$row[1].'<img src="’.$row[3].’" alt="’.$row[2].’" /></td> </tr><tr>’; } else { echo ‘<td>’.$row[1].'<img src="’.$row[3].’" alt="’.$row[2].’" /></td>’; } } echo ‘</tr></tbody></table>’;[/php] or [php]...

CentOS: Update date/time 0

CentOS: Update date/time

Update date/time on CentOS Search for “ntp” [bash]rpm -qa | grep ntp[/bash] If not installed [bash]yum install ntp[/bash] Now it’s a little bit tricky. [bash]ntpdate ### sync up your time date ### verify if it matches up with the date your timezone is set to hwclock ### check the bios clock matches the system clock[/bash] Optional Step [bash]hwclock –systohc ### update bios clock to...