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.";...

Drupal – Get link of image 0

Drupal – Get link of image

In order to get a link of an image, assuming you are using a custom field(type = “image”) use this code: [sourcecode lang=”php”]render(file_create_url($node->field_image_post[‘und’][0][‘uri’]));[/sourcecode]

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.

Ubuntu: Change charset 0

Ubuntu: Change charset

As root, edit /etc/environment using vi/pico/nano to look like this [bash]LANG=C[/bash] Then, change content of /etc/locale.gen to: [bash]en_US.UTF-8 UTF-8 en_US ISO-8859-1 en_US.ISO-8859-15 ISO-8859-15[/bash] Edit /etc/default/locale [bash]LANG=en_US.ISO-8859-15[/bash]

Ubuntu: Run script at startup 0

Ubuntu: Run script at startup

Write your script. Save it in the /etc/init.d/ directory. Lets say you called it FOO. First, make your script executable: [bash]chmod +x FOO[/bash] Then, add it to startup [bash]update-rc.d FOO defaults[/bash]

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...