jQuery datetime picker problem

Some days ago I run into the following problem with jQuery’s datetime picker.

I have a form that contain a input field that I populate with a date/time picker.  If you populate the form on the server with some default values, the jQuery’s hidden fields wont get set unless you do some action on the calendar.

The  solution  is to add inline:true to its options like this:

$(“#myDate”).datepicker({

inline: true,
dateFormat: ‘yy-mm-dd’

});

Nice jQuery Popup Modal Dialog Plugin

One of the best jQuery plugins to display a popup modal window is fancybox

The usage is simple:

$(“.popup”).fancybox();
$.fancybox.resize();

and make sure your link has popup class. It will load the page pointed by your link href and resize as needed.

What if you display a form in the popup and want to reload it with an success message? Use this: $(‘#fancybox-content’).html(data); where data is the content you want to show in popup.

For example, using ajax to submit the form:

$.ajax({
url: ‘exemple.com’,
data: $(‘#form1’).serialize(),
type: ‘post’,
cache: false,
dataType: ‘html’,
success: function (data) {
$(‘#fancybox-content’).html(data);
$.fancybox.resize();
},
error:function (e,data) { alert(e); }
});

PHP – create class properties at runtime

How to dynamically create  in PHP a property for an object?

If the object  is $foo you use this syntax: $this->{$property} = ‘a value’;

For example:

<?php

class foo {

public function setProperty($n, $v)
{
   $this->{$n} = $v;
}

}

$foo = new foo();
$foo->setProperty('property1','value1');
echo $foo->property1; //will display value1
?>

Cookies won’t work in IE if your site is inside an IFRAME

Internet Explorer gives lower level of trust to IFRAME pages (IE calls this “third-party” content). If the page inside the IFRAME doesn’t have a Privacy Policy, its cookies are blocked.

However if you add  a header like this (in PHP) it will work:

header(‘P3P:CP=”NOI CURa ADMa DEVa TAIa OUR BUS IND UNI COM NAV INT”‘);

This sets a  P3P header with a privacy policy that is acceptable to IE, and the cookies will be accepted.

More info: here and here.

A tool for generating policy privacy can be downloaded here.

SQL Server backup script

DECLARE @name VARCHAR(50) — database name
DECLARE @path VARCHAR(256) — path for backup files
DECLARE @fileName VARCHAR(256) — filename for backup
DECLARE @fileDate VARCHAR(20) — used for file name

SET @path = ‘C:\backup\’

SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112)

DECLARE db_cursor CURSOR FOR
SELECT name
FROM master.dbo.sysdatabases
WHERE name NOT IN (‘master’,’model’,’msdb’,’tempdb’)

OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @name

WHILE @@FETCH_STATUS = 0
BEGIN
SET @fileName = @path + @name + ‘_’ + @fileDate + ‘.BAK’
BACKUP DATABASE @name TO DISK = @fileName
–SELECT @fileName
FETCH NEXT FROM db_cursor INTO @name
END

CLOSE db_cursor
DEALLOCATE db_cursor

sursa