1 0
post icon

How to make a string’s first character uppercase in php?

string ucfirst ( string $str )

Returns a string with the first character of str capitalized, if that character is alphabetic.

Leave a Comment
post icon

How to get string from the last occurrence of the space in the string?

$string = substr($row[vodtitle],0,40);
$string = str_replace("-","",$string);
echo substr($string, 0, strrpos( $string, ' ') ); //Hello World
Leave a Comment
post icon

How to copy selected fields from one table to another table in MySQL?

SQL command to copy filed(s) from first table (here “single”) to second table “bank” in field “bankname”.

INSERT INTO `bank` (`bankname`) SELECT distinct `bank` FROM `single`

Leave a Comment
post icon

How to choose random number from a number range?

You can use

$range1 = rand(1, 100);
$range2 = rand(100, 200);
Leave a Comment
post icon

How to remove “Clearbox is ready” popup messages that appear?

Clearbox is a lightbox script based on the jQuery framework. When user loads the page, it shows message “clearbox is ready”,

To disable it go to /clearbox/config/default/cb_config.js

The new code has to be this with “OFF” :
CB_OSD=’off’, // turns on OSD
CB_OSDShowReady=’off’, // when clearbox is loaded and ready, it shows an OSD message

Leave a Comment
post icon

Looping through images in the folder

name of the folder

$dt = $directory = “images/”;

code to loop through each image in the folder
$images = glob($directory . “*.jpg”);
foreach($images as $image)
{

}

Leave a Comment
post icon

Remove “Clearbox is Ready”

To disable it go to /clearbox/config/default/cb_config.js

The new code has to be this with “OFF” :
CB_OSD=’off’, // turns on OSD
CB_OSDShowReady=’off’, // when clearbox is loaded and ready, it shows an OSD message

Leave a Comment
April 14, 2013
post icon

PHP Code to check if its running on ‘localhost’ or not

sometime we have to run two different code’s, one on local machine another set of code on live server.

So to check it

<?php
$url=”http://”.$_SERVER[‘HTTP_HOST’];
if($url == “http://localhost”)
{
//code to be run on local machine
}
else
{
// code to run on server machine
}
?>

Leave a Comment
April 8, 2013
post icon

Uploading image using class.upload.php

Uploading Image using “class.upload.php” for various image size’s.

 

if ($handle->uploaded) {
$handle->file_new_name_body   = $name;
$handle->image_resize         = true;
$handle->image_x              = 170;
$handle->image_ratio_y        = true;
$handle->process($savepath);

$handle->image_watermark       = ‘nbs-logo.png’;
$handle->image_watermark_position = ‘R’;

//medium image size
$savepath = “ians/Photo/”.$date.”/med/”;
$handle->file_new_name_body   = $name;
$handle->image_resize         = true;
$handle->image_x              = 800;
$handle->image_ratio_y        = true;
$handle->process($savepath);

//original image size
$savepath = “ians/Photo/”.$date.”/ori/”;
$handle->file_new_name_body   = $name;
$handle->image_resize         = false;
$handle->process($savepath);

}

Leave a Comment
February 14, 2013
post icon

Find oldest mail, message from Gmail Account

sometime we have to search for our first email we got in Gmail account, here is the trick

1. login to gmail account

2. click on this link (or copy paste this https://mail.google.com/mail/#search//p99999)

 

Leave a Comment