Replace Character Codes using PHP.

Thursday, August 6, 2009

How to replace character codes for german using str_replace php function. Characters such as :

ä
Ä'
é
ö
Ö
ü
Ü
Other chars.

see simple example.

 <?php
$find ="ü";
$rep = "u";
$str = "aüstin";
echo str_replace($find,$rep,utf8_encode($str));
?>

Convert excel to CSV file using PHP, Linx Server

Friday, July 24, 2009

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_clean();
?>

You can download reader.php file from http://sourceforge.net/projects/phpexcelreader/

Set php.ini values into .htaccess file

Thursday, July 23, 2009

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

Friday, June 26, 2009

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>
<input id="URL" name="URL" type="text">
<input type="button" value="Go" onclick='goFor()'/>
</BODY>
</HTML>

How to Replace All in Javascript

Sunday, June 14, 2009

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.

Saturday, June 13, 2009

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: // setting a variable for child SWF File
16: Application.application.parameters.childVar=txt.text;
17:
18: tw = PopUpManager.createPopUp(this,SWFPlaceHolder,true) as SWFPlaceHolder;
19: tw.title = title;
20: tw.width=600;
21: tw.height=400;
22: tw.launchSWF(swfFilePath);
23: }
24:
25: public function getValueFromChildSWF():void{
26: // geting value from child SWF File
27: Alert.show(Application.application.parameters.parentVar,"Parent App");
28: }
29: ]]>
30: </mx:Script>
31: <mx:VBox width="100%" height="100%" paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">
32: <mx:HBox width="100%" horizontalAlign="center" verticalAlign="middle">
33: <mx:Label text="Set Value For Child SWF File " />
34: </mx:HBox>
35:
36: <mx:HBox width="100%" horizontalAlign="center" verticalAlign="middle">
37: <mx:TextArea id="txt" width="100%" height="200">
38: <mx:text>
39: Hello World for Child SWF.....
40: </mx:text>
41: </mx:TextArea>
42: </mx:HBox>
43: <mx:HBox width="100%" horizontalAlign="center" verticalAlign="middle">
44: <mx:Button label="Click to Lanuch External SWF File" id="btn" click="{this.launchExternalSWF('Launch Child SWF File','ExternalSWF.swf')}" />
45: <mx:Button label="Get Value From Child SWF File" id="btn1" click="{this.getValueFromChildSWF()}" />
46: </mx:HBox>
47: </mx:VBox>
48: </mx:Application>
49:



Here is another File for loading swf file SWFFilePlaceHolder.mxml


CODE:
1:  <?xml version="1.0" encoding="utf-8"?>
2: <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="500" height="500" creationComplete="{PopUpManager.centerPopUp(this)}" showCloseButton="true" close="{PopUpManager.removePopUp(this)}">
3: <mx:Script>
4: <![CDATA[
5: import mx.events.CloseEvent;
6: import mx.managers.PopUpManager;
7: import mx.controls.Alert;
8:
9: public function launchSWF(path:String):void{
10: swf.source = path;
11: this.addEventListener(CloseEvent.CLOSE,swfUnload);
12:
13: }
14:
15: public function swfUnload(evt:Event):void{
16: swf.source = null;
17: }
18: ]]>
19: </mx:Script>
20: <mx:SWFLoader id="swf" width="100%" height="100%" />
21: </mx:TitleWindow>
22:


This is The Child or External SWF Flex File Child.mxml

CODE:
1:  <?xml version="1.0" encoding="utf-8"?>
2: <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundColor="White">
3: <mx:Script>
4: <![CDATA[
5: import mx.controls.Alert;
6: public function getValueFromParentSWF():void{
7: Alert.show("Parent App Value:\n"+ Application.application.parameters.childVar,"Child SWF");
8: this.setValueForInternalSWF();
9: }
10:
11: public function setValueForInternalSWF():void{
12: Application.application.parameters.parentVar = txt.text;
13: }
14: ]]>
15: </mx:Script>
16: <mx:Panel label="Child App" width="100%" height="100%">
17: <mx:VBox width="100%" height="100%">
18: <mx:HBox width="100%" horizontalAlign="center" verticalAlign="middle">
19: <mx:Label text="Set Value For Parent SWF File " />
20: </mx:HBox>
21: <mx:HBox width="100%" horizontalAlign="center" verticalAlign="middle">
22: <mx:TextArea id="txt" width="100%" height="200" keyDown="setValueForInternalSWF()">
23: <mx:text>
24: Hello World for Parent SWF.....
25: </mx:text>
26: </mx:TextArea>
27: </mx:HBox>
28: <mx:HBox width="100%" horizontalAlign="center" verticalAlign="middle">
29: <mx:Button label="Click To Get Value From Parent App Textarea" click="getValueFromParentSWF()" />
30: </mx:HBox>
31: </mx:VBox>
32:
33: </mx:Panel>
34: </mx:Application>
35:

How To Read RSS Using PHP

Friday, June 12, 2009

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#

Wednesday, June 10, 2009

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 ?

Monday, June 8, 2009

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.


See example..
<!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>
</BODY>
</HTML>