WEB SQL query in Flash?

Discussion in 'OT Technology' started by jdw, Dec 14, 2007.

  1. jdw

    jdw New Member

    Joined:
    Dec 31, 2005
    Messages:
    4,429
    Likes Received:
    0
    Location:
    ND
    Working on a project at work. Can you query a database out of Flash? I'm so under-experience with flash it hurts.
     
  2. 2ofdem

    2ofdem OT Supporter

    Joined:
    Jun 17, 2003
    Messages:
    114,854
    Likes Received:
    8
    Location:
    aus.vic.mel
    yeah you can use PHP to talk to flash and obviously you can use PHP to do whatever SQL.
     
  3. jdw

    jdw New Member

    Joined:
    Dec 31, 2005
    Messages:
    4,429
    Likes Received:
    0
    Location:
    ND
    hmmm....

    going to have to do some research tomorrow...

    I need it to query the database and stuff the results into a 2D array to display from...

    They gave me a purchased flash file that reads and displays an XML feed but frankly it's not going to integrate real well without me rebuilding it completely anyway. Going to try and use something similar for displaying the results of a query (list of blogs)...
     
  4. 95vr4

    95vr4 OT Supporter

    Joined:
    Oct 6, 2004
    Messages:
    2,513
    Likes Received:
    0
    Location:
    Weddington, NC
    Use php to make your sql query and pass it back to flash with xml. I haven't done much with flash, I know that was the only way to do it with adobe flex though.
     
  5. jdw

    jdw New Member

    Joined:
    Dec 31, 2005
    Messages:
    4,429
    Likes Received:
    0
    Location:
    ND
    I guess I need to figure out how to pass it into flash without saving the XML. The program I have now is reading off a saved XML file and I can't have it running a query and saving an XML file each time the page loads....
     
  6. 95vr4

    95vr4 OT Supporter

    Joined:
    Oct 6, 2004
    Messages:
    2,513
    Likes Received:
    0
    Location:
    Weddington, NC
    You should be able to post the variables to php then have php format the xml. I don't use much php, but here's an example from one of my asp scripts of posting xml and parsing the response, should be even easier in php

    Code:
    ' query UPS service by XML
        
        shipmentIndex=0
        
        
        DataToSend=""
        DataToSend=DataToSend&"<?xml version=""1.0""?><AccessRequest xml:lang=""en-US"">"
        DataToSend=DataToSend&"<AccessLicenseNumber>"&pUpsLicense&"</AccessLicenseNumber><UserId>"&pUpsUser&"</UserId><Password>"&pUpsPassword&"</Password></AccessRequest>"
        DataToSend=DataToSend&"<?xml version=""1.0""?><RatingServiceSelectionRequest xml:lang=""en-US""><Request><TransactionReference>"
        DataToSend=DataToSend&"<CustomerContext>Shipment Rate</CustomerContext><XpciVersion>1.0001</XpciVersion></TransactionReference>"
        DataToSend=DataToSend&"<RequestAction>Rate</RequestAction><RequestOption>Shop</RequestOption></Request>"
        DataToSend=DataToSend&"<PickupType><Code>"&pUpsPickupType&"</Code></PickupType>"
        DataToSend=DataToSend&"<Shipment><Shipper><Address><PostalCode>"&pCompanyZip&"</PostalCode><CountryCode>"&pCompanyCountryCode&"</CountryCode></Address></Shipper>"
        DataToSend=DataToSend&"<ShipTo><Address><PostalCode>"&pFilterZip&"</PostalCode><CountryCode>"&pFilterCountryCode&"</CountryCode>"
        
        If pUpsResidentialAddress then DataToSend=DataToSend&"<ResidentialAddressIndicator/>" 
        
        DataToSend=DataToSend&"</Address></ShipTo>"
        DataToSend=DataToSend&"<Package><PackagingType><Code>"&pUpsPackagingType&"</Code></PackagingType>"
        
        if pMaxLength>0 then 
           DataToSend=DataToSend&"<Dimensions><UnitOfMeasurement><Code>IN</Code></UnitOfMeasurement><Length>"&pMaxLength&"</Length><Width>"&pSumWidth&"</Width><Height>"&pMaxHeight&"</Height></Dimensions>"
        end if
        
        DataToSend=DataToSend&"<PackageWeight><UnitOfMeasurement><Code>LBS</Code></UnitOfMeasurement><Weight>"&pCartTotalWeight&"</Weight></PackageWeight>"
        DataToSend=DataToSend&"</Package></Shipment></RatingServiceSelectionRequest>"
        
    'call sendmail (pCompany, pEmailSender, "", "UPS Debug", DataToSend)    
    
        set xmlhttp = server.Createobject("Microsoft.XMLHTTP")
        ' Testing at xmlhttp.Open "POST","https://wwwcie.ups.com/ups.app/xml/Rate",false
        xmlhttp.Open "POST","https://www.ups.com/ups.app/xml/Rate",false
        xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
        xmlhttp.send DataToSend
        strRetval=xmlhttp.responseText
        'response.write strRetval &"<br><br>"
        set xmlhttp=nothing
        
        ' parse response
        set wobjXMLDoc         = CreateObject("MSXML.DOMDocument")
        wobjXMLDoc.async     = False
        wvarResult         = wobjXMLDoc.loadXML(strRetval)
        
        For Each child In wobjXMLDoc.selectNodes("RatingServiceSelectionResponse/RatedShipment")
            shipmentsArray(shipmentIndex,0)    = getUpsServiceName(child.selectSingleNode("Service/Code").text)
               pShipping    = child.selectSingleNode("TotalCharges/MonetaryValue").text
               if pShippingCountryCode="US" or pShippingCountryCode="" then
            pShipping=pShipping*1.8
            'Half off for AK and HI Sale
             if pStateCode="HI" then
             pShipping=pShipping/2
             end if
             if pStateCode="AK" then
             pShipping=pShipping/2
             end if
            'End half off code
            pShipping=FormatNumber(pShipping,2)
            shipmentsArray(shipmentIndex,1)    = pShipping
            else
                '30% for standard (service code 11)
                if (child.selectSingleNode("Service/Code").text)="11" then
                pShipping=pShipping*1.75
                else
                pShipping=pShipping*.85
                end if
            'Half off for INTL customers Sale
             pShipping=pShipping/2
            'End half off code
            pShipping=FormatNumber(pShipping,2)
            shipmentsArray(shipmentIndex,1)    = pShipping
            end if
               shipmentsArray(shipmentIndex,2)    = pUpsTotalHandling
               pSessionData            = pSessionData&shipmentsArray(shipmentIndex,0)&"%%"&shipmentsArray(shipmentIndex,1)&"%%"&shipmentsArray(shipmentIndex,2)&"||"
               shipmentIndex            = shipmentIndex+1
        Next
        
        set wobjXMLDoc=nothing
     
    Last edited: Dec 14, 2007
  7. jdw

    jdw New Member

    Joined:
    Dec 31, 2005
    Messages:
    4,429
    Likes Received:
    0
    Location:
    ND
    I'll have to read through that when I quit drinking... :naughty:


    I think I'd rather use something like java for this.. but I guess if I can get something done dynamically in flash and let it be for a while I'll take it and run. I know there's something else they have an XML feed for that they want to use this packaged flash file for, but either way it's going to take a lot of modification to make it work/fit where we want it.
     
  8. Dnepr

    Dnepr Guest

    :werd:
     
  9. Dnepr

    Dnepr Guest

    You cant explicitely access database from Flash as far as I know, so you'll have to implement something like this anyways.

    Honestly it'd be loads easier to do in php then in java given the current context :hs:
     
  10. jdw

    jdw New Member

    Joined:
    Dec 31, 2005
    Messages:
    4,429
    Likes Received:
    0
    Location:
    ND

    the java would be the interactivity portion of it....

    Probably have to do it in cold fusion anyway.

    I'll play around with it Monday.
     

Share This Page