How to fetch multi-lingual content from database

The basic purpose of this post is to guide you all about fetching multilingual content from database.
I mean to say that, if you have stored japanese text in your database, So in order to fetch the japanese content , you need to set the character encoding to UTF-8 format, while communication with the database for fetching the result.

In Case of MYSQLi

query(“SELECT ColumnName FROM tableName “)) {
printf(“Select returned %d rows.\n”, $result->num_rows);

/* free result set */
$result->close();
}
$mysqli->close();
?>

In case you are using multiple database

If you don’t pass in “true” to mysqli_connect() in the example below, $link1 and $link2 will have the same resource id# and both database connections will end up being set to utf-8 charsets.

How to convert bitmap image(.jpg , .jpeg, .gif, .png) to vector format (.ai , .eps, .svg)

For converting bitmap image to vector image you need to have autotrace library installed .

If you not installed you can install that bu using the command “yum install autotrace”.

Follow the instruction step till the installation is complete.

Once its installed you can use the below command to convert the image to vector format.

$ autotrace testInputImage.png -output-file testOutputImage.svg

Other example :

$autotrace –input-format=jpg –output-file=tshirt.ai –dpi=1024 –color-count=256 –despeckle-level=0 –despeckle-tightness=0 –corner-always-threshold=60 –line-threshold=0.1 –width-weight-factor=0.1 –line-reversion-threshold=0.1 –preserve-width –remove-adjacent-corners tshirt.ai 2>&1

and your are done.

For more information and option visit http://autotrace.sourceforge.net

Thanks

GD support

How to check if GD support is enabled or not.

<?php
var_dump(gd_info());
?>

If GD support is enabled then you will get an array in that you will get “GD Version”.

If you didn’t get this that means GD support is not there .

To enable GD support you should install
GD library by the below command
“yum install php-gd” (Fedora Linux)
This will install GD support.

Now when you check the output of the above php code it will display the GD version

integrate window media player in your website

<html>
<head></head>
<body leftmargin=”0″ topmargin=”0″>
<table cellpadding=”0″ cellspacing=”0″ border=”0″>
<tr height=”350″><td align=”center”>
<table cellpadding=”0″ cellspacing=”0″ border=1 bordercolor=”black”>
<tr>
<td valign=”top”>
<OBJECT ID=”MediaPlayer” WIDTH=”320″ HEIGHT=”290″ CLASSID=”CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95″ STANDBY=”Loading Windows Media Player components…” TYPE=”application/x-oleobject”>
<PARAM NAME=”URL” VALUE=’http://localhost/vinod/meeting_with_the_boss.wmv’ />
<param name=”AudioStream” value=”0″ />
<param name=”AutoSize” value=”1″ />
<param name=”AutoStart” value=”-1″ />
<param name=”AnimationAtStart” value=”1″ />
<param name=”AllowScan” value=”-1″ />
<param name=”AllowChangeDisplaySize” value=”-1″ />
<param name=”AutoRewind” value=”0″ />
<param name=”Balance” value=”0″ />
<param name=”BufferingTime” value=”1″ />
<param name=”ClickToPlay” value=”1″ />
<param name=”CursorType” value=”0″ />
<param name=”CurrentPosition” value=”-1″ />
<param name=”CurrentMarker” value=”0″ />
<param name=”DisplayBackColor” value=”0″ />
<param name=”DisplayForeColor” value=”16777215″ />
<param name=”DisplayMode” value=”0″ />
<param name=”DisplaySize” value=”4″ />
<param name=”Enabled” value=”1″ />
<param name=”EnableContextMenu” value=”1″ />
<param name=”EnableFullScreenControls” value=”1″ />
<param name=”EnableTracker” value=”0″ />
<param name=”Filename” VALUE=’http://localhost/vinod/meeting_with_the_boss.wmv’><param name=”Mute” value=”0″ />
<param name=”PlayCount” value=”1″ />
<param name=”PreviewMode” value=”1″ />
<param name=”SelectionStart” value=”-1″ />
<param name=”SelectionEnd” value=”-1″ />
<param name=”SendKeyboardEvents” value=”0″ />
<param name=”SendMouseClickEvents” value=”0″ />
<param name=”SendMouseMoveEvents” value=”0″ />
<param name=”SendPlayStateChangeEvents” value=”-1″ />
<param name=”ShowCaptioning” value=”0″ />
<param name=”ShowAudioControls” value=”1″ />
<param name=”ShowDisplay” value=”0″ />
<param name=”ShowGotoBar” value=”0″ />
<param name=”ShowPositionControls” value=”0″ />
<param name=”ShowTracker” value=”1″ />
<param name=”VideoBorderWidth” value=”0″ />
<param name=”VideoBorderColor” value=”0″ />
<param name=”VideoBorder3D” value=”0″ />
<param name=”Volume” value=”-1″ />
<param name=”WindowlessVideo” value=”0″ />
<param name=”ShowStatusBar” value=”1″ />
<PARAM name=”ShowControls” VALUE=”1″ />
<PARAM name=”ShowControls” VALUE=”true” />
<param name=”ShowStatusBar” value=”true” />
<PARAM name=”ShowDisplay” VALUE=”false” />
<EMBED TYPE=”application/x-mplayer2″ SRC=’http://localhost/vinod/meeting_with_the_boss.wmv’ NAME=”MediaPlayer” WIDTH=”320″ HEIGHT=”290″ ShowControls=”1″ ShowStatusBar=”1″ ShowDisplay=”0″ autostart=”1″> </EMBED></OBJECT>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>

You can view the live application here

Calculate no of years,month,days,hours,minutes and seconds past since given date

function getYMDHMSPastFromTwoDate($startTimeStamp,$endTimeStamp)
{
$years = ”;
$Month = ”;
$Days = ”;
$Hrs = ”;
$Mins = ”;
$totalSecs = ”;
$timePastArr = array();
$date1 = $startTimeStamp;
$date2 = $endTimeStamp;
if($date1 > $date2)
{
$dateDiff = intval($date1 – $date2);
}
else
{
$dateDiff = intval($date2 – $date1);
}

$totalYears = $dateDiff/(365*24*60*60);
$years = floor($totalYears);
$timeRemaining = ($dateDiff – ($years*365*24*60*60));
$totalMonth = $timeRemaining/(30*24*60*60);
$Month = floor($totalMonth);
$timeRemaining = $timeRemaining – $Month*30*24*60*60;
$totalDays = $timeRemaining/(24*60*60);
$Days = floor($totalDays);
$timeRemaining = $timeRemaining-$Days*60*60*24;
$totalHrs = $timeRemaining/(60*60);
$Hrs = floor($totalHrs);
$timeRemaining = $timeRemaining-$Hrs*60*60;
$totalMins = $timeRemaining/60;
$Mins = floor($totalMins);
$timeRemaining = $timeRemaining-$Mins*60;
$totalSecs = floor($timeRemaining);

return $timePastArr = array(‘year’=>$years,’month’=>$Month,’days’=>$Days,’hours’=>$Hrs,’minutes’=>$Mins,’seconds’=>$totalSecs);

}