Wednesday, July 23, 2008

Audio Streaming / Playing audio mp3 files in web page - HTML

How to play mp3 files in a web page - as streaming using some players available for free?...

First, lets try with windows media player.
Try this code...
<object id="MediaPlayer" height=46 classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95" standby="Loading Windows Media Player components..." type="application/x-oleobject" codebase=",4,7,1112">
<param name="filename" value="Bheema1.mp3">
<param name="Showcontrols" value="True">
<param name="autoStart" value="True">
<embed type="application/x-mplayer2" src="" name="MediaPlayer"></embed>

will Show this media player:

This one is from google... Google audio player.
<embed type="application/x-shockwave-flash" src="" width="400" height="27" allowscriptaccess="never" quality="best" bgcolor="#ffffff" wmode="window" flashvars="playerMode=embedded" />

will Show:

This is from yahoo...
<embed src='' width='400' height='40' wmode='transparent' flashVars='playlist_url=,0,0,0&skin_color_2=0,0,0,0' type='application/x-shockwave-flash' pluginspage=''/>

will Show:

And this one is very cute...
Add just a line (javascript) in your page and get the player...


Random Number / Alpha Numeric Password Generation in PHP

To generate random no.s we can use rand() function...
echo ran() ; //will generate random no between 0 and32768
echo rand(5,200); //a random no between 5 and 200

To generate alpha numeric random no - uniqid()...
echo uniqid(rand(), true);
you can get a number like:
274134886dbd37292e8.16885304 (32 digit)

To generate alpha numeric passwords for user accounts use this:
$password = substr (MD5(uniqid(rand(),1)), 3, 10); //10 digit random alpha numeric password



Friday, July 4, 2008

Doctype - margin / padding problem with HTML

Some may come across the problem...


if you use any doctype in our page, then some unwanted padding/margin will appear with images / tables / td s will be added automatically in your page....

You want to remove them...? Then add this css code in to your page

html, body, div, span, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, code,
del, dfn, em, img, q, dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
margin: 0;
padding: 0;
border: 0;

Thats all...

Saving Textarea value with enter / Line feed / Line break in PHP

In save forms into database... the value in the text area cant be saved with the line feed that user gives.

To get them we can use the following function...

consider the textarea name is description.... then we can convert the line feed in the form of '\n' or '\r' into <br />

$desc = $_REQUEST['description'];
$desc = ereg_replace("(\r\n|\n|\r)", "<br />", $_desc);