Remove the dotted line on links

junio 4, 2008

Worried of an awful dotted line arround your web links? Kill them NOW! :P

You can do it with this simple CSS trick:

a:active, a:focus
{
width:0; height:0;
outline:0;
}

That’s all ;) Thanks to the inspiration


Text Encoding on a mail from PHP

mayo 9, 2008

I must add this to my last post…

Probably, encoding your mails with php mail routine get you a big headache… I propose this two simple solutions:

  1. Work with UTF-8 everywhere it’s easy and it works :) (It’s the better idea)
  2. But working with ISO-9985 you’ll probably get wrong characters on the mail subject.
    You can try this (inspired on a more complete solution for this problem by GeoLand):
    $subject
    = “=?iso-8859-1?B?”.base64_encode(“text on subject with symbols! áéíñóöê…”).“?=”;

Good Luck!


Send mail from PHP script

marzo 26, 2008

Simple, but practical when you want to send emails from your php webpages :) Enjoy it!

<?php
// Config email recipient

$to = "user@emailprovider.com";

// Config email subject
$subject = "Happy birthday!";

// Config text to send
$body = "Hi!!!\n\nI've got a big present for you! See you later :P ";

// Config email sender
$headers = "From: CompleteName <mymail@emailprovider.com>";

// Send it and notify it's success
if ( mail($to, $subject, $body, $headers) ) {

echo("<p>Mail sent! :) </p>");

} else {

echo("<p>Delivery failed! :( </p>");

}
?>

Note that you can specify complete name and his address for email sender… For example:

// Config email sender
$headers = "From: Douglas Adams <hitchhikers@guidetogalaxy.com>";


Email Validation with Javascript Regular Expressions

marzo 11, 2008

It doesn’t cover all RFC822 addresses but it’s pretty simple!

/^[a-zA-Z0-9._-]+([+][a-zA-Z0-9._-]+){0,1}[@]
[a-zA-Z0-9._-]+[.][a-zA-Z]{2,6}$/

Handles:

  • Plus addressing: user+filter@host.toplevel
  • Dotted user and domain: u.s.e.r@host.multi.level.toplevel
  • Special top level domains: user@example.museum

But if you want the perfect RegExp RFC compilant… you must consider this RegExp of more than 6 thousand caracters long.


First Frame Still on Web-Embedded Windows Media Player

marzo 10, 2008

On WMP there isn’t any implemented solution to show “first frame” (or any still you want) when video hasn’t started… but we can manage with this simple codes:

Wherever you want your Media Player just put this

<iframe name=“video” src=“still.html” height=230 width=280 scrolling=“no” frameborder=“0″></iframe>

On a new file named still.html:

 <a href=“player.html”><img src=“./still.bmp” height=230 width=280 border=“0″ /></a>

Note that you must have still.bmp or whatever image you want…

 still

And finally player.html builds Media Player as follows:

<object classid=”clsid:22d6f312-b0f6-11d0-94ab-0080c74c7e95″ codebase=”http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab” width=”243″ height=”212″ border=”0″ align=”baseline”>
<param name=”FileName” value=”mms://bombur.esade.edu/md/casos/FerrofetCatalana/09.wmv”>
<param name=”AutoStart” value=”true”>
<param name=”ShowControls” value=”true”>
<param name=”ShowPositionControls” value=”false”>
<param name=”ShowAudioControls” value=”true”>
<param name=”ShowTracker” value=”true”>
<param name=”ShowStatusBar” value=”false”>
<param name=”AutoSize” value=”true”>
<param name=”AutoRewind” value=”false”>
<param name=”AllowScan” value=”true”>
<param name=”EnableContextMenu” value=”true”>
<param name=”bgcolor” value=”white”>
<embed width=“280″ height=“230″ border=”0″ align=”baseline” src=“video.wmv” autostart=”true” showcontrols=”true” controller=”true” showpositioncontrols=”false” showaudiocontrols=”true” showtracker=”true” showstatusbar=”false” autosize=”true” scale=”aspect” autorewind=”false” allowscan=”true” enablecontextmenu=”true” pluginspage=”http://www.microsoft.com/Windows/MediaPlayer/download/”> </embed>
</object>

Good luck!


Easy PHP Form-to-MySQL & get autoincrement id

febrero 19, 2008

<?php

// Select db on connection
mysql_select_db($database, $connection);

$query = "INSERT INTO table ( ";
$values = " VALUES ( ";

foreach($_POST as $var => $value) {

if($var!="Submit")
{

$query .= $var.", ";
$values .= "'".$value."', ";

}

}

// Extract the undesired last comma
$query = substr($consulta,0,strlen($query)-2).")";
$values = substr($valors,0,strlen($values)-2).")";

$query .= $valors;

mysql_query($query, $connection) or die(mysql_error());

// and you can get autoincremented "id" it with this
$id = mysql_insert_id();

?>

If you’re trying to send HTTP post vars from a form to a mysql database with php this will help you to get all your vars well organized… you must have the same names everywhere :)


Detect Memory Leaks on Windows

febrero 19, 2008

// Declare the variables needed
#ifdef _DEBUG

CMemoryState oldMemState, newMemState, diffMemState;
oldMemState.Checkpoint();

#endif

// Do your memory allocations and deallocations.
CString s("This is a frame variable");
// The next object is a heap object.
CPerson* p = new CPerson( "Smith", "Alan", "581-0215" );

#ifdef _DEBUG

newMemState.Checkpoint();
if( diffMemState.Difference( oldMemState, newMemState ) )
{

TRACE( "Memory leaked!\n" );
diffMemState.DumpStatistics();

}

#endif


Seguir

Get every new post delivered to your Inbox.