<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>

<channel>
	<title>Code Snippets</title>
	<atom:link href="http://vikku.info/codesnippets/feed/" rel="self" type="application/rss+xml" />
	<link>http://vikku.info/codesnippets</link>
	<description>Jayapal Chandran's  Code Snippets - JavaScript, Ajax, PHP, C 16bit and WIN32 API</description>
	<pubDate>Thu, 01 Jul 2010 15:11:21 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>forcing javascript to abort - stop javascript execution at any time</title>
		<link>http://vikku.info/codesnippets/javascript/forcing-javascript-to-abort-stop-javascript-execution-at-any-time/</link>
		<comments>http://vikku.info/codesnippets/javascript/forcing-javascript-to-abort-stop-javascript-execution-at-any-time/#comments</comments>
		<pubDate>Thu, 01 Jul 2010 14:26:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[abort javascript]]></category>

		<guid isPermaLink="false">http://vikku.info/codesnippets/?p=205</guid>
		<description><![CDATA[How do we abort  JavaScript execution at any instance even inside a loop. 
Create a function with a name jsexit or jsabort
and have this as its code

function javascript_abort&#40;&#41;
&#123;
   throw new Error&#40;'This is not an error. This is just to abort javascript'&#41;;
&#125;

instead of the error string which i have given you can give [...]]]></description>
			<content:encoded><![CDATA[<p>How do we abort  JavaScript execution at any instance even inside a loop. </p>
<p>Create a function with a name jsexit or jsabort<br />
and have this as its code</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> javascript_abort<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
   <span style="color: #000066; font-weight: bold;">throw</span> <span style="color: #003366; font-weight: bold;">new</span> Error<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'This is not an error. This is just to abort javascript'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>instead of the error string which i have given you can give any string you want. This is really working well for me.</p>
<p>call it anywhere like javascript_abort()<br />
for example</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// assume that you have this code inside a nested function.</span>
<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span><span style="color: #CC0000;">10</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
     <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">==</span><span style="color: #CC0000;">5</span><span style="color: #009900;">&#41;</span>javascript_abort<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #006600; font-style: italic;">//so at any place it will stop the execution.</span></pre></div></div>

<p>But in IE browsers you will see an yellow exclamation to indicate that there is an error in the javascript. </p>
<p>Otherwise every thing is perfect i believe. In other browsers this will not appear. If you have enabled error reporting add-on for firefox then it would show a graphic notification. that too is not at all a problem.</p>
<p>If anybody (the users) clicks the yellow exclamation in IE they see this string as error message &#8216;This is not an error. This is just to abort javascript&#8217;.</p>
<p>But still i need an option to exit javascript execution without making IE or any other browsers that an error has occured when a new error has been thrown.</p>
<p>I would like to have comments, suggestion and objections about this because i would like to know what people think about this.</p>
]]></content:encoded>
			<wfw:commentRss>http://vikku.info/codesnippets/javascript/forcing-javascript-to-abort-stop-javascript-execution-at-any-time/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Failed to write session data Please verify the current setting of session.save_path</title>
		<link>http://vikku.info/codesnippets/php/failed-to-write-session-data-please-verify-that-the-current-setting-of-sessionsave_path/</link>
		<comments>http://vikku.info/codesnippets/php/failed-to-write-session-data-please-verify-that-the-current-setting-of-sessionsave_path/#comments</comments>
		<pubDate>Mon, 21 Jun 2010 10:43:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://vikku.info/codesnippets/?p=200</guid>
		<description><![CDATA[I was updating a project. When i checked my work i got this warning and in could not login in to the site.
Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp).
Then i searched and got the following snippet and it worked but still i have to make [...]]]></description>
			<content:encoded><![CDATA[<p>I was updating a project. When i checked my work i got this warning and in could not login in to the site.<br />
Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/tmp).</p>
<p>Then i searched and got the following snippet and it worked but still i have to make it bug free and i am working on it but not immediate.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">session_save_path</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/home/site/public_html/session'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'session.gc_probability'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>I created a directory &#8217;session&#8217; in the root folder and gave the write permission.<br />
The above script is just an example.<br />
I ran the script and it worked.</p>
<p>Here we have to think about how the old session files are deleted and what is the need for the ini setting session.gc.probability&#8230; instead of me explaining this you better go to the url which i have given below.</p>
<p>If you face the same problem and try the above. And then you should read this article. I, yet to completely test that only then i can post anything here.</p>
<p><a href="http://www.captain.at/howto-php-sessions.php">http://www.captain.at/howto-php-sessions.php</a></p>
<p>If anybody would like to give me more information about this the you can comment on this. And your objections are welcomed.</p>
]]></content:encoded>
			<wfw:commentRss>http://vikku.info/codesnippets/php/failed-to-write-session-data-please-verify-that-the-current-setting-of-sessionsave_path/feed/</wfw:commentRss>
		</item>
		<item>
		<title>show html elements on top of youtube video - youtube embed z index - wmode transparent</title>
		<link>http://vikku.info/codesnippets/php/show-html-elements-on-top-of-youtube-video-make-youtube-video-wmode-transparent/</link>
		<comments>http://vikku.info/codesnippets/php/show-html-elements-on-top-of-youtube-video-make-youtube-video-wmode-transparent/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 07:02:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://vikku.info/codesnippets/?p=196</guid>
		<description><![CDATA[Assume that you are managing youtube videos in your site admin panel. So they are dynamically displayed in web pages.
Youtube video embed code, as i have seen does not include the option of making the video go behind HTML elements.
When we do some animation you can see that the youtube video is on top of [...]]]></description>
			<content:encoded><![CDATA[<p>Assume that you are managing youtube videos in your site admin panel. So they are dynamically displayed in web pages.<br />
Youtube video embed code, as i have seen does not include the option of making the video go behind HTML elements.<br />
When we do some animation you can see that the youtube video is on top of all. </p>
<p>So we need to include the wmode transparent option in the embedd code before displaying.<br />
This attribute(param) will make the youtube video go behing any popups.</p>
<p>Here is the simple code to insert the wmode transparent option into the url before displaying it.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'youtubevideo'</span>&gt;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$url</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//youtube video url from database</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;embed&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&lt;param name='wmode' value='transparent'&gt;&lt;/param&gt;&lt;embed&quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$string</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;embed&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;&lt;embed wmode='transparent' &quot;</span><span style="color: #339933;">,</span><span style="color: #000088;">$string</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">echo</span> <span style="color: #000088;">$string</span><span style="color: #339933;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></div></div>

<p>&#8230;<br />
<a href='http://vikku.info/codesnippets/php/replace-width-and-height-of-html-element-using-regular-expression/'>How to replace the width and height of an embed code or youtube video</a></p>
]]></content:encoded>
			<wfw:commentRss>http://vikku.info/codesnippets/php/show-html-elements-on-top-of-youtube-video-make-youtube-video-wmode-transparent/feed/</wfw:commentRss>
		</item>
		<item>
		<title>print div content - Print only the content of an HTML element and not the whole document</title>
		<link>http://vikku.info/codesnippets/javascript/print-div-content-print-only-the-content-of-an-html-element-and-not-the-whole-document/</link>
		<comments>http://vikku.info/codesnippets/javascript/print-div-content-print-only-the-content-of-an-html-element-and-not-the-whole-document/#comments</comments>
		<pubDate>Sun, 25 Apr 2010 11:39:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://vikku.info/codesnippets/?p=193</guid>
		<description><![CDATA[This snippet will print the contents of any html element and not the entire page.
Get the contents of the innerhtml of the element. Here it is a div. We are going to print the contents of a div.
Define an iframe (better before this script).
This iframe is hidden on the screen by giving the style so [...]]]></description>
			<content:encoded><![CDATA[<p>This snippet will print the contents of any html element and not the entire page.<br />
Get the contents of the innerhtml of the element. Here it is a div. We are going to print the contents of a div.<br />
Define an iframe (better before this script).<br />
This iframe is hidden on the screen by giving the style so and so.<br />
Get a reference to the iframe&#8217;s contentwindow so that you can write the contents of the div in to the body of the iframe.<br />
Use the close command like in the script else you can see that the browser is still loading the page even if you have completely written all the text into the content window.<br />
So when you do close call you specify that there is no more contents to write to.<br />
And then we make the iframe as the active window because when you print the active windows total body content will gets printed.<br />
and then we call the print command. voila.<br />
Without any modification this code snippet works well for me so hope it would be the same case for you guys.</p>
<p>The JavaScript code</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> content <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;divcontents&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> pri <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ifmcontentstoprint&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">contentWindow</span><span style="color: #339933;">;</span>
pri.<span style="color: #660066;">document</span>.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pri.<span style="color: #660066;">document</span>.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span>content.<span style="color: #660066;">innerHTML</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pri.<span style="color: #660066;">document</span>.<span style="color: #000066;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pri.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
pri.<span style="color: #000066;">print</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The HTML Code</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">iframe</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ifmcontentstoprint&quot;</span> <span style="color: #000066;">style</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;height: 0px; width: 0px; position: absolute&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">iframe</span>&gt;</span></pre></div></div>

<p>Why the need of an iframe?<br />
as you all know when you print the whole document gets printed.<br />
So we create a hidden new document with the help of an iframe and we assign the contents we want to print to the body of the iframe.<br />
So the iframe will contain only the contents which we want to print.<br />
And since the iframe is hidden everything will appear normal at the same the work is done.</p>
]]></content:encoded>
			<wfw:commentRss>http://vikku.info/codesnippets/javascript/print-div-content-print-only-the-content-of-an-html-element-and-not-the-whole-document/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Scroll DIV, HTML elements using Javascript</title>
		<link>http://vikku.info/codesnippets/javascript/scroll-div-html-elements-using-javascript/</link>
		<comments>http://vikku.info/codesnippets/javascript/scroll-div-html-elements-using-javascript/#comments</comments>
		<pubDate>Sat, 03 Apr 2010 07:27:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://vikku.info/codesnippets/?p=189</guid>
		<description><![CDATA[Javascript Code

&#60;script&#62;
var sc, maxscroll, minscroll=0;
var uptime, downtime
var pixelsteps=5;
window.onload = function&#40;&#41;
&#123;
	sc = document.getElementById&#40;'wn3'&#41;;
	maxscroll = sc.scrollHeight - sc.offsetHeight
	minscroll = 0		
&#125;
&#160;
function scrollup&#40;&#41;
&#123;
	uptime = window.setInterval&#40;'scrollUp()',1&#41;
&#125;
function scrolldown&#40;&#41;
&#123;
	downtime = window.setInterval&#40;'scrollDown()',1&#41;
&#125;
&#160;
function scrollUp&#40;&#41;
&#123;
	if&#40;sc.scrollTop&#62;0&#41;
		sc.scrollTop = sc.scrollTop - pixelsteps
	window.location.hash = sc.scrollTop		
&#125;
function scrollDown&#40;&#41;
&#123;
	if&#40;sc.scrollTop&#60;maxscroll&#41;
		sc.scrollTop = sc.scrollTop +  pixelsteps
	window.location.hash = sc.scrollTop
&#125;
&#160;
function clearscroll&#40;&#41;
&#123;
	if&#40;uptime&#41;window.clearInterval&#40;uptime&#41;
	if&#40;downtime&#41;window.clearInterval&#40;downtime&#41;	
&#125;
&#60;/script&#62;

HTML Code

&#160;
&#60;img src=&#34;up.gif&#34; onmousedown=&#34;scrollup();&#34; onmouseup=&#34;clearscroll();&#34; /&#62;&#60;br&#62;
&#60;img src=&#34;dn.gif&#34; onmousedown=&#34;scrolldown();&#34; onmouseup=&#34;clearscroll()&#34;  /&#62;


== Version 2 ==

var sc, maxscroll, [...]]]></description>
			<content:encoded><![CDATA[<p>Javascript Code</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script<span style="color: #339933;">&gt;</span>
<span style="color: #003366; font-weight: bold;">var</span> sc<span style="color: #339933;">,</span> maxscroll<span style="color: #339933;">,</span> minscroll<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> uptime<span style="color: #339933;">,</span> downtime
<span style="color: #003366; font-weight: bold;">var</span> pixelsteps<span style="color: #339933;">=</span><span style="color: #CC0000;">5</span><span style="color: #339933;">;</span>
window.<span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	sc <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'wn3'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	maxscroll <span style="color: #339933;">=</span> sc.<span style="color: #660066;">scrollHeight</span> <span style="color: #339933;">-</span> sc.<span style="color: #660066;">offsetHeight</span>
	minscroll <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span>		
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> scrollup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	uptime <span style="color: #339933;">=</span> window.<span style="color: #660066;">setInterval</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'scrollUp()'</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> scrolldown<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	downtime <span style="color: #339933;">=</span> window.<span style="color: #660066;">setInterval</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'scrollDown()'</span><span style="color: #339933;">,</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> scrollUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>sc.<span style="color: #660066;">scrollTop</span><span style="color: #339933;">&gt;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>
		sc.<span style="color: #660066;">scrollTop</span> <span style="color: #339933;">=</span> sc.<span style="color: #660066;">scrollTop</span> <span style="color: #339933;">-</span> pixelsteps
	window.<span style="color: #660066;">location</span>.<span style="color: #660066;">hash</span> <span style="color: #339933;">=</span> sc.<span style="color: #660066;">scrollTop</span>		
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> scrollDown<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>sc.<span style="color: #660066;">scrollTop</span><span style="color: #339933;">&lt;</span>maxscroll<span style="color: #009900;">&#41;</span>
		sc.<span style="color: #660066;">scrollTop</span> <span style="color: #339933;">=</span> sc.<span style="color: #660066;">scrollTop</span> <span style="color: #339933;">+</span>  pixelsteps
	window.<span style="color: #660066;">location</span>.<span style="color: #660066;">hash</span> <span style="color: #339933;">=</span> sc.<span style="color: #660066;">scrollTop</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> clearscroll<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>uptime<span style="color: #009900;">&#41;</span>window.<span style="color: #660066;">clearInterval</span><span style="color: #009900;">&#40;</span>uptime<span style="color: #009900;">&#41;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>downtime<span style="color: #009900;">&#41;</span>window.<span style="color: #660066;">clearInterval</span><span style="color: #009900;">&#40;</span>downtime<span style="color: #009900;">&#41;</span>	
<span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>HTML Code</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;up.gif&quot;</span> <span style="color: #000066;">onmousedown</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;scrollup();&quot;</span> <span style="color: #000066;">onmouseup</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;clearscroll();&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">br</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dn.gif&quot;</span> <span style="color: #000066;">onmousedown</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;scrolldown();&quot;</span> <span style="color: #000066;">onmouseup</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;clearscroll()&quot;</span>  <span style="color: #66cc66;">/</span>&gt;</span></pre></div></div>

<p></p>
<p>== Version 2 ==</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> sc<span style="color: #339933;">,</span> maxscroll<span style="color: #339933;">,</span> minscroll<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> uptime<span style="color: #339933;">,</span> downtime
<span style="color: #003366; font-weight: bold;">var</span> pixelsteps<span style="color: #339933;">=</span><span style="color: #CC0000;">2</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> delay <span style="color: #339933;">=</span> <span style="color: #CC0000;">10</span>
<span style="color: #003366; font-weight: bold;">function</span> inscroll<span style="color: #009900;">&#40;</span>src<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>arguments.<span style="color: #660066;">length</span><span style="color: #339933;">&gt;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span>pixelsteps <span style="color: #339933;">=</span> arguments<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span>	
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>arguments.<span style="color: #660066;">length</span><span style="color: #339933;">&gt;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span>delay <span style="color: #339933;">=</span> arguments<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span>		
&nbsp;
	sc <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>src<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	maxscroll <span style="color: #339933;">=</span> sc.<span style="color: #660066;">scrollHeight</span> <span style="color: #339933;">-</span> sc.<span style="color: #660066;">offsetHeight</span>
	minscroll <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span>		
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> scrollup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	uptime <span style="color: #339933;">=</span> window.<span style="color: #660066;">setInterval</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'scrollUp()'</span><span style="color: #339933;">,</span>delay<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> scrolldown<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	downtime <span style="color: #339933;">=</span> window.<span style="color: #660066;">setInterval</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'scrollDown()'</span><span style="color: #339933;">,</span>delay<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> scrollUp<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>sc.<span style="color: #660066;">scrollTop</span><span style="color: #339933;">&gt;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>
		sc.<span style="color: #660066;">scrollTop</span> <span style="color: #339933;">=</span> sc.<span style="color: #660066;">scrollTop</span> <span style="color: #339933;">-</span> pixelsteps
<span style="color: #009900;">&#125;</span>
<span style="color: #003366; font-weight: bold;">function</span> scrollDown<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>sc.<span style="color: #660066;">scrollTop</span><span style="color: #339933;">&lt;</span>maxscroll<span style="color: #009900;">&#41;</span>
		sc.<span style="color: #660066;">scrollTop</span> <span style="color: #339933;">=</span> sc.<span style="color: #660066;">scrollTop</span> <span style="color: #339933;">+</span>  pixelsteps
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> clearscroll<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>uptime<span style="color: #009900;">&#41;</span>window.<span style="color: #660066;">clearInterval</span><span style="color: #009900;">&#40;</span>uptime<span style="color: #009900;">&#41;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>downtime<span style="color: #009900;">&#41;</span>window.<span style="color: #660066;">clearInterval</span><span style="color: #009900;">&#40;</span>downtime<span style="color: #009900;">&#41;</span>	
<span style="color: #009900;">&#125;</span></pre></div></div>

<p></p>
<p>You have to call inscroll(&#8217;divid&#8217;,pixelincrementvalue,delay);</p>
]]></content:encoded>
			<wfw:commentRss>http://vikku.info/codesnippets/javascript/scroll-div-html-elements-using-javascript/feed/</wfw:commentRss>
		</item>
		<item>
		<title>force download - authenticated download</title>
		<link>http://vikku.info/codesnippets/php/force-download-authenticated-download/</link>
		<comments>http://vikku.info/codesnippets/php/force-download-authenticated-download/#comments</comments>
		<pubDate>Wed, 18 Nov 2009 10:51:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://vikku.info/codesnippets/?p=182</guid>
		<description><![CDATA[Basically downloads are normal direct link to real files in the server with a complete static url link to the file. So any body can click the link and can download the file. Any cross site script can access the file any time or any user can access the file from anywhere.
What if you want [...]]]></description>
			<content:encoded><![CDATA[<p>Basically downloads are normal direct link to real files in the server with a complete static url link to the file. So any body can click the link and can download the file. Any cross site script can access the file any time or any user can access the file from anywhere.</p>
<p>What if you want to allow file downloads only if the user is logged in.<br />
what if you want to hide the actual file and its folder from displaying it to the user instead you want to show a different url which could probably be a server side script file (.php for example). and that could fetch the actual file with a different name. </p>
<p>For that i use the force download concept. I will just send the id of a file for which its filename and location are always hidden. take this for example&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'sitename.com/files/files.php?id=45'</span>&gt;</span>Click here to download<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span></pre></div></div>

<p>and in files.php firstly i will check whether the users has logged in and only then i will let the file to download&#8230; else nothing happens.</p>
<p>here is a sample code to do a force download.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//select fn from tablename where id=$_request[id]</span>
<span style="color: #666666; font-style: italic;">//assume that the file is in the junk named folder</span>
<span style="color: #666666; font-style: italic;">// the the force download script will look like the following</span>
&nbsp;
<span style="color: #000088;">$filename</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;doc_O1jtIYi4jkg8Xh2k/<span style="color: #006699; font-weight: bold;">$fn</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Cache-Control: no-store&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Expires: 0&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Type: application/octet-stream&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-disposition: attachment; filename=<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">basename</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Transfer-Encoding: binary&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Content-Length: '</span><span style="color: #339933;">.</span> <span style="color: #990000;">filesize</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">readfile</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filename</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>the readfile function reads the contents of a file and outputs to the client.<br />
cache control no-store if for geko browsers and no-cache can be included for IE browsers<br />
You can either use the exact mime type if you know in the place of content-type.</p>
<p>This works in all browsers. People either download, save and view the file or they directly open the file. When they do the second and if their browser is IE 6 then you get a message that &#8216;cannot access file from temporary internet folder&#8217; so for IE 6 the users has to save the file first and then they have to open it.</p>
<p>If you find any sense if not appropriate then please post a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://vikku.info/codesnippets/php/force-download-authenticated-download/feed/</wfw:commentRss>
		</item>
		<item>
		<title>prevent reloading flash movie on every page by using flashvars</title>
		<link>http://vikku.info/codesnippets/flash/prevent-reloading-flash-movie-on-every-page-by-using-flashvars/</link>
		<comments>http://vikku.info/codesnippets/flash/prevent-reloading-flash-movie-on-every-page-by-using-flashvars/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 08:21:31 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://vikku.info/codesnippets/?p=167</guid>
		<description><![CDATA[You can prevent the flash showing the loading progress on each page by using the flashvars.
I wanted the menus in flash to be highlighted when the page is under that menu. for example i have home, about, services, contact. now i am in home page. when i click services page that page loads and i [...]]]></description>
			<content:encoded><![CDATA[<p>You can prevent the flash showing the loading progress on each page by using the flashvars.</p>
<p>I wanted the menus in flash to be highlighted when the page is under that menu. for example i have home, about, services, contact. now i am in home page. when i click services page that page loads and i want services to be highlighted in a different color. so when ever you are in any page the menu for that page should be highlighted. for doing that i use.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;movie&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;flash/header2_fv8.swf?button=0&quot;</span>&gt;</span></pre></div></div>

<p> the number for button will vary for each menu. the button number is the reference for menus which are to be highlighted when a page is in view.</p>
<p>so on any page  home can be button 0 and so on&#8230; and in html of any page what ever button number you give in object tag that menu in the flash is highlighted&#8230; </p>
<p>if you use a query string directly like</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">object</span> <span style="color: #000066;">data</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;flash/header2_fv8.swf?button=0&quot;</span>&gt;</span></pre></div></div>

<p> or </p>
<p>like</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;movie&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;flash/header2_fv8.swf?button=0&quot;</span>&gt;</span></pre></div></div>

<p> then for every page load </p>
<p>the flash movie will show the loading progress.</p>
<p>The reason might be that every time you send a query string and flash could assume it as a </p>
<p>new url and it loads as if it is loading for the first time. just an assumption. and some </p>
<p>people too said so.</p>
<p>so to prevent this that is to prevent flash to show the loading progress again and again<br />
you can use the FlashVars attribute like in the following.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">&lt;param name=&quot;movie&quot; value=&quot;flash/header2_fv8.swf?button=0&quot;&gt;</pre></div></div>

<p>here is a sample code</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">object</span> <span style="color: #000066;">classid</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&quot;</span> <span style="color: #000066;">codebase</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,24&quot;</span> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;980&quot;</span> <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;394&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;movie&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;flash/header2_fv8.swf&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;quality&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;high&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;menu&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;wmode&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;transparent&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;FlashVars&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;button=1&quot;</span>&gt;</span>
&nbsp;
&nbsp;
      <span style="color: #808080; font-style: italic;">&lt;!--[if !IE]&gt; &lt;--&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">object</span> <span style="color: #000066;">data</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;flash/header2_fv8.swf&quot;</span> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;980&quot;</span> <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;394&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;application/x-shockwave-flash&quot;</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;quality&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;high&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
	<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;FlashVars&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;button=1&quot;</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;menu&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;pluginurl&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.macromedia.com/go/getflashplayer&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;wmode&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;transparent&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>       
      <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">object</span>&gt;</span>
&nbsp;
      <span style="color: #808080; font-style: italic;">&lt;!--&gt; &lt;![endif]--&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">object</span>&gt;</span></pre></div></div>

<p>&#8230;<br />
&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://vikku.info/codesnippets/flash/prevent-reloading-flash-movie-on-every-page-by-using-flashvars/feed/</wfw:commentRss>
		</item>
		<item>
		<title>session side effect session.bug_compat_42 or session.bug_compat_warn</title>
		<link>http://vikku.info/codesnippets/php/session-side-effect-sessionbug_compat_42-or-sessionbug_compat_warn/</link>
		<comments>http://vikku.info/codesnippets/php/session-side-effect-sessionbug_compat_42-or-sessionbug_compat_warn/#comments</comments>
		<pubDate>Sat, 08 Aug 2009 06:33:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://vikku.info/codesnippets/?p=163</guid>
		<description><![CDATA[Warning: Unknown: Your script possibly relies on a session
side-effect which existed until PHP 4.2.3. Please be advised that
the session extension does not consider global variables as a
source of data, unless register_globals is enabled. You can disable
this functionality and this warning by setting
session.bug_compat_42 or session.bug_compat_warn to off,
respectively. in Unknown on line 0
This error likely appears when [...]]]></description>
			<content:encoded><![CDATA[<p>Warning: Unknown: Your script possibly relies on a session<br />
side-effect which existed until PHP 4.2.3. Please be advised that<br />
the session extension does not consider global variables as a<br />
source of data, unless register_globals is enabled. You can disable<br />
this functionality and this warning by setting<br />
session.bug_compat_42 or session.bug_compat_warn to off,<br />
respectively. in Unknown on line 0</p>
<p>This error likely appears when setting some thing like this $_SESSION['something'] = NULL; or you are assigning a variables value to a session which is null. hopefully.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">what people say is better turn off this warning by
&nbsp;
1. &quot;session.bug_compat_42 = 0&quot; in your php.ini
&nbsp;
2. setting the following in your .htaccess file
    php_flag session.bug_compat_42 0
    php_flag session.bug_compat_warn 0
&nbsp;
3. Directly write the following code in your php script where you want to 
stop the warning. It is better if you set it in a common include file.
&nbsp;
ini_set('session.bug_compat_42',0);
ini_set('session.bug_compat_warn',0);
...</pre></div></div>

<p>&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://vikku.info/codesnippets/php/session-side-effect-sessionbug_compat_42-or-sessionbug_compat_warn/feed/</wfw:commentRss>
		</item>
		<item>
		<title>embedding flash in html for XHTML strict doc type</title>
		<link>http://vikku.info/codesnippets/html/embedding-flash-in-html-for-w3c-strict-doc-type/</link>
		<comments>http://vikku.info/codesnippets/html/embedding-flash-in-html-for-w3c-strict-doc-type/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 10:06:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://vikku.info/codesnippets/?p=159</guid>
		<description><![CDATA[Normally when we include flash html code it will have an object tag which will have a child  tag which works well i all browsers with html document type transitional.
When we set html document type to strict then w3c validation shows error on embed tag. So what could be the alternate to include a [...]]]></description>
			<content:encoded><![CDATA[<p>Normally when we include flash html code it will have an object tag which will have a child <embed> tag which works well i all browsers with html document type transitional.</p>
<p>When we set html document type to strict then w3c validation shows error on embed tag. So what could be the alternate to include a flash code for w3c strict mode.</p>
<p>i found this code in google codes&#8230; and i have given the link below to the resource which is in detail and also has a java script alternate of including flash content in a html page.</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;">&nbsp;
      <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">object</span> <span style="color: #000066;">classid</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&quot;</span> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;780&quot;</span> <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;420&quot;</span>&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">param</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;movie&quot;</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;myContent.swf&quot;</span> <span style="color: #66cc66;">/</span>&gt;</span>
        <span style="color: #808080; font-style: italic;">&lt;!--[if !IE]&gt;--&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">object</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;application/x-shockwave-flash&quot;</span> <span style="color: #000066;">data</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;myContent.swf&quot;</span> <span style="color: #000066;">width</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;780&quot;</span> <span style="color: #000066;">height</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;420&quot;</span>&gt;</span>
        <span style="color: #808080; font-style: italic;">&lt;!--&lt;![endif]--&gt;</span>
          <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;</span>Alternative content<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
        <span style="color: #808080; font-style: italic;">&lt;!--[if !IE]&gt;--&gt;</span>
        <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">object</span>&gt;</span>
        <span style="color: #808080; font-style: italic;">&lt;!--&lt;![endif]--&gt;</span>
      <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">object</span>&gt;</span></pre></div></div>

<p>the complete documentation can be found at the following url&#8230;</p>
<p><a href="http://code.google.com/p/swfobject/wiki/documentation">http://code.google.com/p/swfobject/wiki/documentation</a></p>
<p>&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://vikku.info/codesnippets/html/embedding-flash-in-html-for-w3c-strict-doc-type/feed/</wfw:commentRss>
		</item>
		<item>
		<title>sending mail from localhost in php</title>
		<link>http://vikku.info/codesnippets/php/sending-mail-from-localhost-in-php/</link>
		<comments>http://vikku.info/codesnippets/php/sending-mail-from-localhost-in-php/#comments</comments>
		<pubDate>Tue, 21 Jul 2009 13:06:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://vikku.info/codesnippets/?p=151</guid>
		<description><![CDATA[Use the basic phpmailer code which comes with the phpmailer zip form phpclasses.org
the following code is the default one which sends mail from your server by using the default server settings.
the host name is set to localhost and authentication is false(which takes the default). these are the two lines which
vary when sending mail form localhost.

include&#40;&#34;includes/phpmailer/class.phpmailer.php&#34;&#41;;
&#160;
$mail [...]]]></description>
			<content:encoded><![CDATA[<p>Use the basic phpmailer code which comes with the phpmailer zip form phpclasses.org<br />
the following code is the default one which sends mail from your server by using the default server settings.</p>
<p>the host name is set to localhost and authentication is false(which takes the default). these are the two lines which<br />
vary when sending mail form localhost.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;includes/phpmailer/class.phpmailer.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$mail</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> phpmailer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">PluginDir</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/include/&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">IsSMTP</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// send via SMTP</span>
&nbsp;
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">From</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;noreplysample.com&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">FromName</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;From Name&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">AddAddress</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;address@host.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">WordWrap</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">65</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// set word wrap</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">IsHTML</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// send as HTML</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Subject</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Mail Subject&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">SMTPAuth</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// turn off SMTP authentication			</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Host</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;localhost&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// SMTP servers</span>
&nbsp;
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Body</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$msg</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">send</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>the code to send mail form your localhost to any remote email server<br />
the difference in the above and the following is i have given the important part which need to send mail from localhost<br />
the first below two lines differ from the above. and the last two lines are added.<br />
you have to give your servers auth information to send mail. So when ever mail is sent from localhost to a remote server<br />
a server reference is needed. which means&#8230; mail is sent form localhost on-behalf of your server.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">SMTPAuth</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// turn on SMTP authentication</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Host</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;samplesite.com&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// SMTP servers</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Userame</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;testing@testing.com&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Password</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;testing&quot;</span><span style="color: #339933;">;</span></pre></div></div>

<p>so when the above lines gets executed this code connects to your site for verification<br />
and then the mail is sent with reference to your server. so<br />
you need a server by using which you can send mails from localhost.</p>
<p>here is the full code which sends mail from localhost.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">include</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;includes/phpmailer/class.phpmailer.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$mail</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> phpmailer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">PluginDir</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/include/&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">IsSMTP</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// send via SMTP</span>
&nbsp;
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">From</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;noreplysample.com&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">FromName</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;From Name&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">AddAddress</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;address@host.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">WordWrap</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">65</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// set word wrap</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">IsHTML</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// send as HTML</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Subject</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Mail Subject&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">SMTPAuth</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span> 						
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Host</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;samplesite.com&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// SMTP servers</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Userame</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;testing@samplesite.com&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Password</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;testing&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Body</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$msg</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">send</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>the from address should be a valid domain string. else mostly your mail will not be sent.</p>
<p>&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://vikku.info/codesnippets/php/sending-mail-from-localhost-in-php/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
