Archive for January, 2009

using ODBC with PHP

Friday, January 23rd, 2009

Connecting to ODBC

There is an excellent tutorial on using PHP’s ODBC extension at ASPToday, a popular ASP web site. An example taken from the above article:

<?
# connect to a DSN "mydb" with a user and password "marin"
$connect = odbc_connect("mydb", "marin", "marin");

# query the users table for name and surname
$query = "SELECT name, surname FROM users";

# perform the query
$result = odbc_exec($connect, $query);

# fetch the data from the database
while(odbc_fetch_row($result)){
  $name = odbc_result($result, 1);
  $surname = odbc_result($result, 2);
  print("$name $surname\n");
}

# close the connection
odbc_close($connect);
?>

flex-Validating form data

Friday, January 23rd, 2009

http://www.adobe.com/devnet/flex/quickstart/validating_data/

Submitting a Flex form using PHP

Friday, January 23rd, 2009
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml” layout=”absolute”>
  <mx:HTTPService id=”srv” url=”http://www.rudysportfolio.com/flexTest/mail.php” method=”POST”>
    <mx:request>
  <user>{user.text}</user> 
      <email>{email.text}</email>
      <message>{message.text}</message>
    </mx:request>
  </mx:HTTPService>
  <mx:Form>
    <mx:FormItem label=”Name”>
      <mx:TextInput id=”user”/>
    </mx:FormItem>
    <mx:FormItem label=”Email”>
      <mx:TextInput id=”email”/>
    </mx:FormItem>
    <mx:FormItem label=”Message”>
     <mx:TextArea width=”211″ height=”117″ id=”message” />
    </mx:FormItem>     
    <mx:FormItem>
      <mx:Button label=”Submit” click=”srv.send()”/>
    </mx:FormItem>
  </mx:Form>
</mx:Application>

and my php file:

<?php

$address = “rugu87@hotmail.com”;

$subject = “subject line tester”;

$body = $_POST[’user’] . ” had this to say:\n” . stripslashes($_POST[’message’]);

$extra_header_str = “From:” . $_POST[’email’];

$mailsend = mail($address,$subject,$body,$extra_header_str);

echo $mailsend;

?>



				

Flex-Webservice - validate Zipcode

Friday, January 23rd, 2009

The following example adds a web service to process form input data. In this example, the user enters a ZIP code, and then selects the Submit button. After performing any data validation, the submit event listener calls the web service to obtain the city name, current temperature, and forecast for the ZIP code.

<?xml version="1.0"?>
<!-- containers\layouts\FormDataSubmitServer.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

    <!-- Define the web service connection.
        The specified WSDL URI is not functional. -->
    <mx:WebService id="WeatherService"
        wsdl="/ws/WeatherService?wsdl">
        <mx:operation name="GetWeather">
            <mx:request>
                <ZipCode>{zipCode.text}</ZipCode>
            </mx:request>
        </mx:operation>
    </mx:WebService>

    <mx:Script>
        <![CDATA[
            private function processValues():void {
                // Check to see if ZIP code is valid.
                WeatherService.GetWeather.send();
            }
        ]]>
    </mx:Script>

    <mx:Form>
        <mx:FormItem label="Zip Code">
               <mx:FormHeading label="Zip Code Form"/>
            <mx:TextInput id="zipCode"
                width="200"
                text="Zip code please?"/>
            <mx:Button
                width="60"
                label="Submit"
                click="processValues();"/>
        </mx:FormItem>
    </mx:Form>

    <mx:VBox>
        <mx:TextArea
            text=
              "{WeatherService.GetWeather.lastResult.CityShortName}"/>
        <mx:TextArea
            text=
              "{WeatherService.GetWeather.lastResult.CurrentTemp}"/>
        <mx:TextArea
            text=
          "{WeatherService.GetWeather.lastResult.DayForecast}"/>
    </mx:VBox>
</mx:Application>


The following example adds a load event and a fault event to the form. In this example, the form is defined as one child of a ViewStack container, and the form results are defined as a second child of the ViewStack container:

<?xml version="1.0"?>
<!-- containers\layouts\FormDataSubmitServerEvents.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

    <!-- Define the web service connection.
        The specified WSDL URI is not functional. -->
    <mx:WebService id="WeatherService"
        wsdl="/ws/WeatherService?wsdl"
        result="successfulCall();"
        fault="errorCall();">
        <mx:operation name="GetWeather">
            <mx:request>
                <ZipCode>{zipCode.text}</ZipCode>
            </mx:request>
        </mx:operation>
    </mx:WebService>

    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;

            private function processValues():void {
                // Check to see if ZIP code is valid.
                WeatherService.GetWeather.send();
            }

            private function successfulCall():void {
                vs1.selectedIndex=1;
            }

            private function errorCall():void {
                Alert.show("Web service failed!", "Alert Box", Alert.OK);
            }
        ]]>
    </mx:Script>

    <mx:ViewStack id="vs1">
        <mx:Form>
               <mx:FormHeading label="Zip Code Form"/>
               <mx:FormItem label="Zip Code">
                <mx:TextInput id="zipCode"
                    width="200"
                    text="Zip code please?"/>
                <mx:Button width="60"
                    label="Submit"
                    click="processValues();"/>
            </mx:FormItem>
        </mx:Form>

        <mx:VBox>
            <mx:TextArea
                text=
                    "{WeatherService.GetWeather.lastResult.CityShortName}"/>
            <mx:TextArea
                text=
                    "{WeatherService.GetWeather.lastResult.CurrentTemp}"/>
            <mx:TextArea
                text=
                    "{WeatherService.GetWeather.lastResult.DayForecast}"/>
        </mx:VBox>
    </mx:ViewStack>
</mx:Application>

Slumdog Millionair

Sunday, January 4th, 2009

Kung Fu Panda

Sunday, January 4th, 2009


Your Ad Here