Skip to main content

Posts

Showing posts from 2009

Convert excel to CSV file using PHP, Linx Server

How to convert xls file into csv file using php or LAMP, Look at simple example to convert excel to csv file using php on linux server. <?php require_once 'Excel/reader.php'; $excel = new Spreadsheet_Excel_Reader(); $excel->setOutputEncoding('CP1251'); $excel->read('b.xls'); $x=1; $sep = ","; ob_start(); while($x<=$excel->sheets[0]['numRows']) { $y=1; $row=""; while($y<=$excel->sheets[0]['numCols']) { $cell = isset($excel->sheets[0]['cells'][$x][$y]) ? $excel->sheets[0]['cells'][$x][$y] : ''; $row.=($row=="")?"\"".$cell."\"":"".$sep."\"".$cell."\""; $y++; } echo $row."\n"; $x++; } $fp = fopen("data.csv",'w'); fwrite($fp,ob_get_contents()); fclose($fp); ob_end_cl

Set php.ini values into .htaccess file

How can i set php.ini configuration values into .htaccess file? Here is the simple solution to set php.ini variables into .htaccess file. Syntax non flag variables. php_value setting_name setting_value Example : php_value upload_max_filesize 10M Syntax for flag variables such as (on/off). php_flag [variable_name] [value] Exmaple : php_flag register_globals off

Send HTML Form Elements Value Without Using Form Tag

How to send form components value without using Form Tag in HTML, ? This example will help your to send HTML elements value from one page to another page without using HTML Form Tag. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT=""> <META NAME="Author" CONTENT=""> <META NAME="Keywords" CONTENT=""> <META NAME="Description" CONTENT=""> </HEAD> <BODY> <script language="javascript"> function goFor(){ var ele = document.getElementById("URL"); if(ele.value==""){ alert("Please Enter URL."); }else{ location.href="http://www.google.com?q="+ele.value; } } </script&g

How to Replace All in Javascript

How to replace all string using javascript replace function... Here is simple example replace all in javascript in replace string method. CODE: <Script Language="javascript"> var str = "This is the test string."; var rs = str.replace(/is/g,""); document.write(st); // result "Th the test string." </Script>

How to send variables from on SWF flex file to another SWF file Using Flex.

How to Communicate From one SWF Flex file to another SWF Flex File ? See the below example, This is loading external swf flex file into parent SWF File and sharing the data or variable from parent to child and child to parent. Parent.mxml CODE: 1: <?xml version="1.0" encoding="utf-8"?> 2: <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="100%" height="100%"> 3: <mx:Script> 4: <![CDATA[ 5: import mx.events.CloseEvent; 6: import mx.controls.SWFLoader; 7: import mx.managers.PopUpManager; 8: import mx.containers.TitleWindow; 9: import mx.controls.Alert; 10: 11: public var tw:SWFPlaceHolder; 12: 13: public function launchExternalSWF(title:String,swfFilePath:String):void{ 14: 15: /

How To Read RSS Using PHP

Here is the simple code to read RSS Feeds using php with simpladxml_load_string function. CODE: 1 :   <?php 2 :        $displayItems = 5; 3 :        $itemCounter = 0; 4 :        $rss = simplexml_load_file("http://put here url of RSS Feed"); 5 :        foreach($rss->channel->item as $feeds){ 6 :             $itemCounter++; 7 :             echo '<li><a href="'.$feeds->link.'">'.$feeds->title.'</a><br /><br />'; 8 :             if($itemCounter==$displayItems)break; 9 :        } 10 :   ?>

How to Check Local Machine Name and IP Address Using C#

How to check client Machine or local Machine Name and IP address using C-sharp, See the below simple example code. CODE: 1 : using System.Net; 2 : 3 : string hostName = Dns.GetHostName(); 4 : IPHostEntry ie = Dns.GetHostByName(hostName); 5 : IPAddress[] ia= ie.AddressList; 6 : 7 : MessageBox.Show("Local Machine Name : "+hostName.ToString()); 8 : MessageBox.Show("IP address Of Local Machine "+ipAddress[0].ToString());

How to Check Internet Connection Using C-Sharp

How to check internet connection using c#? Here is a simple example to find out internet connection or page response using c -Sharp CODE: 1 : Using System.Net ; 2 : try{ 3 : HttpWebRequest request= (HttpWebRequest) HttpWebRequest.Create("google.com"); 4 : HttpWebResponse response= (HttpWebResponse) request.GetResponse(); 5 : if (HttpStatusCode.OK == response.StatusCode) 6 : { 7 : //Write here your code... 8 : response.Close(); 9 : } 10 : }catch (Exception ex){ 11 : MessageBox.Show("Unable to connect"); 12 : }

How to Format My Source Code For Blogger ?

How to format my source code for blogger, blog, Blogging, weblog & website ? Now you can format you source code for blogger, blog, Blogging, weblog & website using online source code formatter. This application build in javascript. This source code beautifier or formatter provide for your blogger, Blog and websites a good code indentation. You can can format your source code with alternative background using <pre> tag. It does not add unnecessary tags in formatted source code excpet <pre> and <code> so just try onto your source code for blog or blogging & website posts . This is absolutly free online line source code formatter tool for your blogger & website. http://codeformatter.blogspot.com/ See example.. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New Document </TITLE> <META NAME="Generator" CONTENT=""> <META NAME="A

Search Records into XML Using PHP

There is an example for search items or block into xml using php with simplexml_load_string method or function, this will return you record block for particular query. query = us CODE: 1 :   <?php 2 :        # parm query=delhi , us 3 :        $xmlStr = '<?xml version="1.0" encoding="utf-8"?> 4 :                            <temprature> 5 :                            <item> 6 :                                 <city>Bareilly</city> 7 :                                 <state>Uttar Pradesh</state> 8 :                                 <country>India</country> 9 :                                 <lat>32.4567</lat> 10 :                                 <lon>34.4567</lon> 11 :                                 <temp>43.0</temp> 12 :                            </item> 13 :                            <item> 14 :                                 <city>Haldwani</city&

Center Alignment of popup window Javascript

How to centralized popup window using Javascript. see the below code. CODE: 1 :   var OpenWindows = new Object(); 2 :   function OpenWin(sPath, w, h) 3 :   { 4 :        l = (screen.width - w)/2-5; 5 :        t = (screen.height - h)/2-20; 6 :        if (l<1) l=0; 7 :        if (t<1) t=0; 8 :        sWindowName = "mainwin_" + w + "_" + h; 9 :        if(OpenWindows[sWindowName]) { 10 :             if(!OpenWindows[sWindowName].closed) OpenWindows[sWindowName].close(); 11 :        } 12 :        OpenWindows[sWindowName] = window.open(sPath, sWindowName, "left=" + l + ",top=" + t + ",width=" + w + ",height=" + h + ",scrollbars=no,menubar=no,toolbars=no,status=no"); 13 :        return OpenWindows[sWindowName]; 14 :   }

How To Change Form Action at Runtime

How to change Form action at runtime using javascript. This the example which will change html form action at runtime. CODE: 1 :   <html> 2 :   <head> 3 :   <Script Language="javascript"> 4 :   function change_action(){ 5 :   var frm_obj=document.getElementById("frm"); 6 :   frm_obj.action="http://www.google.com"; 7 :   } 8 :   </Script> 9 :   </head> 10 :   <body> 11 :   <form id="frm" action="abc.php" method="post" onsubmit="return change_action()"> 12 :   UID &nbsp;&nbsp;<input type="text"><br> 13 :   PWD <input type="Password"><br><br> 14 :   <input type="submit" value="submit"> 15 :   </form> 16 :   </body> 17 :   </html>

Change Div Position Randomly on Home Page

Change Div position randomly on home page.here is simple example which display a div randomly on homepage within available width and hight. CODE: 1 :   <Script Langauge="javscript"> 2 :   var load=true; 3 :   var div_width=300; 4 :   var div_height=200; 5 :   var top=Math.floor(Math.random()*screen.availHeight - div_height) 6 :   var left=Math.floor(Math.random()*screen.availWidth - div_width) 7 :   document.write("<div id='pic_div' style='border:1px solid black;position:absolute;width:"+div_width+";height:"+div_height+"; 8 :   text-align:center;left:0px;top:0px'>a</div>"); 9 :   var d_obj=document.getElementById("pic_div"); 10 :   d_obj.style.top=top; 11 :   d_obj.style.left=left; 12 :   </script>

Free Online Meta Tag Creator

Meta Tags are HTML header part tags, which describe about the website . These meta tags provide information to the search engines such as Google, Yahoo, MSN Search, AOL Search, AltaVista ,HotBot, Lycos, Excite and other search engines . It is very important to the search engine point of view meta tags must be well formed and meaningful . HTML Meta tags help to increase your website rank. The common questions arise for meta tags are as follows? What Are META Tags? META Tags are HTML header part tags of HTML Document that provide internal & external information about the content of a web page or website while you are browsing that page you are not able to see that Meta tags on your browser output. How META Tags Work for Search Engine? Meta tag tell to search about the page such as keywords, Description, Content Language etc, which parameter you put in contents attribute of the meta tags that's is read by search engine to index your page with accuracy, which is totally depend to

Use FilterFunction in Flex ArrayCollection

Here is the simple Flex ArrayCollection FilterFunction example to ignore blank records (name) form arrayCollection. var ac=new ArrayCollection(); ac.addItem({name:'abc'}); ac.addItem({name:'xyz'}); ac.addItem({name:''}); ac.addItem({name:'dac'}); // use of fillter function ac.filterFunction = function(item:*):Boolean{ return (StringUtill.trim(item.name)!=""); // } ac.refresh(); Now filtered ArrayCollection object use further code.

Set Script Timeout In PHP

In PHP.ini define a script timeout (max_execution_time) if it's exceed , the script returns a fatal error. The default limit is 30 seconds. to set script max execution time we can use below function. set_time_limit(1000) //1000 seconds OR ini_set("max_execution_time","1000"); //1000 seconds

C Sharp User Define SQL Database Class

This is the simple user define SQL Database Class. It is useful to avoid redundancy of the code. Database Class In C# using System; using System.Data; using System.Data.SqlClient; using System.Configuration; public class _Database { public SqlConnection con; public SqlCommand com = null; public SqlDataReader dr = null; public SqlDataAdapter da = null; public DataSet ds = null; public String glQuery = ""; public String glnonQuery = ""; public const int EXECUTE_NONE_QUERY = 1; public const int EXECUTE_QUERY = 2; public const int DATA_ADAPTER = 3; // connection for data list paging public SqlConnection globalcon = new SqlConnection("server=**;uid=**;pwd=***;Database=**"); public _Database() { } public void Query(String SqlQuery) { this.glQuery = this.Get_DataBasePrefix(SqlQuery); } private String Get_DataBasePrefix(String str) { return str.Replace("#__", "GD_").ToString(); } public void ConnectDB() { try { con = new SqlConnection(); con.Co

FTP File Uploading Using C Sharp

This is the example to upload file using FTP Web Request. using system.net; using system.io; FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create("ftp://myDoc.com/xyz.pdf"); / request.Method = WebRequestMethods.Ftp.UploadFile; request.Credentials = new NetworkCredential(username, password); request.UsePassive = true; request.UseBinary = true; request.KeepAlive = false; //Load the file FileStream stream = File.OpenRead(filePath); //c:/myDoc/xyz.pdf byte[] buffer = new byte[stream.Length]; stream.Read(buffer, 0, buffer.Length); stream.Close(); //Upload file Stream reqStream = request.GetRequestStream(); reqStream.Write(buffer, 0, buffer.Length); reqStream.Close(); btnUpload.UseWaitCursor = false;

Create XML File From Mysql Table

How to create XMLFile Form Mysql Table function createXMLFile($result, $feildLength, $dir) { $headers = array(); $xmlData = array(); $str = ""; $counter = 0; for ($i=0;$i<$feildLength;$i++) { array_push($headers, mysql_field_name($result, $i)); } $xmlFileData = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; while ($row = mysql_fetch_array($result)) { for ($i=0;$i<$feildLength;$i++) { $str .= "<".trim($headers[$i]).">" . escapeXMLEntities(trim($row[$i])) . "</".trim($headers[$i]).">\n"; $counter++; //increment column# if ($counter == $feildLength) { //new row array_push($xmlData, "<record>\n" . $str . "</record>\n"); $str = ""; $counter = 0; } } } $xmlFileData .= "<records name=\"Customer_Table\">\n" . implode("", $xmlData) . "</records&g

Creating Data Grid Using HTTP Service in Flex

Creating Data Grid Using HTTP Service in Flex & displaying data using XML in flex. <?xml version='1.0' /> <Data> <ID>1</ID> <Name>Vineet</Name> </Data> <Data> <ID>2</ID> <Name>Abhishek</Name> </Data> This Data Grid Example will display above xml data in grid. <mx:application mx="http://www.adobe.com/2006/mxml" layout="absolute" creationcomplete="init()"> <mx:httpservice id="xmlFile" url="http://localhost/***/***/project.php" result="getXML(event)" resultformat="e4x" /> <mx:script> <!--[CDATA[ import mx.rpc.events.ResultEvent; [Bindable] --> </mx:script> <mx:panel x="10" y="10" width="100%" height="100%"> <mx:canvas label="XYZ" width="100%" height="100%"> <mx:datagrid x="10" y="10" width="10

Drawing Line and arrow using flex

How to drawing line with arrow in flex? public function addPoint(sX:int,sY:int,eX:int,eY:int, createArrow:Boolean):void { var g:Graphics =this.graphics; g.lineStyle(1, 0xff0000, 1); g.moveTo(sX, sY); g.lineTo(eX, eY); if(createArrow){// drawing arrow g.lineStyle(6, 0x0000ff, 1); g.moveTo(Math.round(eX+((sX-eX)/6)), Math.round(eY+((sY-eY)/6))); // mid point g.lineTo(eX, eY); g.lineStyle(3, 0x00ff00, 1); g.moveTo(Math.round(eX+((sX-eX)/6)), Math.round(eY+((sY-eY)/6))); // mid point g.lineTo(eX, eY); } }

How to use Accordion window in Flex

<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> <mx:Panel x="119" y="63" width="382" height="268" layout="absolute" title="Accordion select"> <mx:HBox width="100%" height="100%" id="hbox6"> <mx:Accordion width="100%" height="100%"> <mx:Canvas width="100%" label="Accordion 1"> </mx:Canvas> <mx:Canvas width="100%" label="Accordion 2"> </mx:Canvas> <mx:Canvas width="100%" label="Accordion 3"> </mx:Canvas> <mx:Canvas width="100%" label="Accordion 4"> </mx:Canvas> </mx:Accordion> </mx:HBox> </mx:Panel> </mx:Application>

Read Mulitiple selected item of List Box Using Flex

How to read multiple selection list box in flex? <mx:List allowMultipleSelection="true" id="searchResult" width="100%" height="100" verticalScrollPolicy="on" click="filter"> <mx:dataProvider> <mx:Object label="Schmidt, Frank" value="1"/> <mx:Object label="Schmidt, Peter" value="2"/> </mx:dataProvider> </mx:List> function filter():void{ var str:String=""; for each(var ob:Object in searchResult.selectedItems){ str+=(str=="")?ob.value.toString():","+ob.value.toString(); i++; } trace(str); // this will return you indexs of list box }

Create Word Document Using PHP

Here is the example of creating word document using php. <?php $wordObj = new COM("word.application") or die ("Could not create an instance of word"); echo "Version : {$wordObj->version}"; $wordObj->visible = 1; $wordObj->Documents->Add(); $wordObj->Selection->TypeText("Hello World.."); // add text here $wordObj->Documents[1]->SaveAs("sample.doc"); // save location $wordObj->Quit(); $wordObj->Release(); //free object $wordObj = null; ?>

How to set Javascript Cookie for Domain

var cookie_date = new Date ( ); // current date & time cookie_date.setTime ( cookie_date.getTime() + 24*60*60*1000 ); // for 1 days Syntax: document.cookie = "CookieName=CookieValue; expires=cookie expire time"; path= directories;domain=domainname"; Example: document.cookie="test=testValue;expires="+ cookie_date.toGMTString()+";path=/dir1/dir2/dir3/;domain=mytest.com";

Convert Image Into Jpeg Using C sharp.

This example is useful to upload image of any format and Convert into JPEG or JPG Using C-Sharp. using System.IO; using System.Drawing; using System.Drawing.Imaging; using System.Reflection; using System.Drawing.Drawing2D; public class _Library { public string w; public string h; public _Library() { } /* for uploading Image */ public String UploadFile(FileUpload Fileobject,String Path) { String FileName = ""; String[] getformat; String imgformat1 = "", imgformat2 = ""; if (Fileobject.HasFile) { FileName = DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + "_" + Fileobject.FileName.Replace(' ','-').ToLower(); Fileobject.SaveAs(@"" + Path + "" + FileName); getformat =FileName.ToString().Split('.'); imgformat1 = getformat[0].ToString(); imgformat2 = getformat[1].ToStrin

Flex Banner Example

Simple Flex Fade in Fade out Banner Example CODE: 1: <?xml version="1.0" encoding="utf-8"?> 2: <mx:Application verticalScrollPolicy="off" verticalGap="0" horizontalGap="0" horizontalScrollPolicy="off" xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" paddingTop="0" paddingLeft="0" paddingRight="0" paddingBottom="0" verticalAlign="middle" backgroundColor="white" creationComplete="{init();}"> 3: <mx:Script> 4: <![CDATA[ 5: import mx.effects.WipeLeft; 6: import mx.events.TweenEvent; 7: import mx.controls.Alert; 8: import mx.events.EffectEvent; 9: import mx.effects.Fade; 10: import mx.effects.Pause; 11: import mx.effects.Sequence; 12: import mx.effects.SetPropertyAction; 13: import mx.effects.WipeRight; 14: private var fader:Sequence; 15: private

R Script Command Line Options

Usage: R [options] [<> outfile] or: R CMD command [arguments] Start R, a system for statistical computation and graphics, with the specified options, or invoke an R tool via the 'R CMD' interface. Options: -h, --help : Print short help message and exit --version : Print version info and exit --encoding=ENC : Specify encoding to be used for stdin RHOME : Print path to R home directory and exit --save : Do save workspace at the end of the session --no-save : Don't save it --no-environ : Don't read the site and user environment files --no-site-file : Don't read the site-wide Rprofile --no-init-file : Don't read the .Rprofile or ~/.Rprofile files --restore : Do restore previously saved objects at startup --no-restore-data : Don't restore previously saved objects --no-restore-history : Don't restore the R history fil

Open Babel command line options

Open Babel command line options are as follows. Open Babel converts chemical structures from one file format to another Usage: babel <input> <output> [Options] Each spec can be a file whose extension decides the format. Optionally the format can be specified by preceding the file by -i<format-type>&e.g. -icml, for input and -o<format-type> for output See below for available format-types, which are the same as the file extensions and are case independent. If no input or output file is given stdin or stdout are used instead. More than one input file can be specified and their names can contain wildcard chars (* and ?).The molecules are aggregated in the output file. Conversion options -f <#> Start import at molecule # specified -l <#> End import at molecule # specified -e Continue with next object after error, if possible -z Compress the output with gzip -k Attempt to translate keywords -H Outputs this help text -Hxxx (xxx is file format ID e.g. -H

Random Layer using javascript

Display random layer/div in javascript <HTML> <Head> <Script Language="javascript"> //global var var last_index=0; box_len=5; function ret_index() { var ran; do{ ran=Math.floor(Math.random()*box_len); if(ran==0)ran=box_len; }while(ran==last_index); last_index=ran; return ran; } function show_one(){ vBox=ret_index(); for(var i=1;i<=box_len;i++){ if(vBox!=i){ obj=document.getElementById("box_0"+i); obj.style.display="none"; }else{ obj=document.getElementById("box_0"+i); obj.style.display="inline"; } } } </Script> <Body> <a href="javascript:show_one();">show One</a> <div id='box_01' style="position:absolute;left:120;width:100;height:100;border:1px solid red;text-align:center"> <br>Box1 </div> <div id='box_02' style="position:absolute;left:240;width:100;height:100;border:1px solid red;text-align:center"> <br>Box2 </div

Dynamic ArrayCollection Using Flex

Creating Dynamic Array Collection Using Flex. var ob:Object; var n:String = "Name"; var a:String = "Address"; var ar:ArrayCollection = ""; ob = new Object(); ob[n] = "Ar"; ob[a] = "xyz, UK"; ar = new ArrayCollection(); ar.addItem(ob); ArrayCollection filterfunction

HTML Meta Tags

The Meta tags are not compulsory tags for HTML or web pages. Meta tags provide information of web page to the search engines. If you put Meta tags in your web page it should be more briefly, these meta tags is used by search engines to index your web pages into their server. If you put brief & more specific meta tags then search engines put your web pages into accurate indexes. Basic Meta tags are Keywords & Description that content length should be less than & equal to near about 255 characters. Keywords Meta tag is used to define keywords of web page. <meta name="Keywords" content="HTML,PHP,ASP"> Description Meta tag is to used define description of web page. <meta name="Description" content="IT Help Desk"> Revised Meta tag is used to define last update of web page <meta name="revised" content="01/11/08" /> Refresh Meta tag used to update web page every 10 seconds. <meta http-equiv="refr