5 Replies Latest reply on Apr 7, 2010 12:29 PM by jimmyoneshot

    Inserting Into MYSQL Table Via Air/PHP = Not Allowed?

    jimmyoneshot Level 1

      I'm having trouble inserting data into my mysql database tables through my air app. All the code is pretty much exactly the same as in some examples I've seen but it simply won't do it. Is this because of some sort of security restriction because the air app is on my machine and the server with my mysql database on is elsehwhere? Or is it possible to insert data via an air app?

       

      Here is the example I've been following:-

       

      http://livedocs.adobe.com/flex/3/html/help.html?content=data_access_2.html

        • 1. Re: Inserting Into MYSQL Table Via Air/PHP = Not Allowed?
          jsd99 Level 3

          There is no MySQL client library for Flash/Air so you have to use an intermediary.  (Even if such a library existed, I would still recommend against using it.)  The page you linked to shows how a Flash app might talk to a PHP application on a webserver to perform the actual database manipulation.

           

          Do you have a webserver?  Does that webserver have PHP (or ruby or whatever) scripts that can deal with your database?  If not, you have to make them, and set up your AIR app to call those scripts.

          1 person found this helpful
          • 2. Re: Inserting Into MYSQL Table Via Air/PHP = Not Allowed?
            Matt Le Fevre Level 4

            AIR does has an embedded SQLlite database though which you can use without an intermediary.

             

            http://www.adobe.com/devnet/air/flex/articles/flickr_floater_05.html

             

            why not use that?

            1 person found this helpful
            • 3. Re: Inserting Into MYSQL Table Via Air/PHP = Not Allowed?
              jimmyoneshot Level 1

              Thanks for the answers boys. I've decided I'm going to change it into a flex app instead as then there won't be any problems. It simply means I'll have to add a logon system to it.

               

              While were on the subject do you guys happen to know of any examples anywhere of how someone can REMOVE data from an sql table via flex/php?

               

              What I'm looking for is basically when a user uses my app and enters info into some text inputs, if that specfic info exists within a table then that data will be removed from the table. The way this works is that they will choose an item within a tilelist which is populated by the data from this mysql table and this will insert the data of the selected item into the text inputs and then they click a remove button to remove that item. Can't find anything similar anywhere though.

              • 4. Re: Inserting Into MYSQL Table Via Air/PHP = Not Allowed?
                Matt Le Fevre Level 4

                jimmyoneshot wrote:

                 

                Thanks for the answers boys. I've decided I'm going to change it into a flex app instead as then there won't be any problems. It simply means I'll have to add a logon system to it.

                 

                While were on the subject do you guys happen to know of any examples anywhere of how someone can REMOVE data from an sql table via flex/php?

                 

                What I'm looking for is basically when a user uses my app and enters info into some text inputs, if that specfic info exists within a table then that data will be removed from the table. The way this works is that they will choose an item within a tilelist which is populated by the data from this mysql table and this will insert the data of the selected item into the text inputs and then they click a remove button to remove that item. Can't find anything similar anywhere though.

                 

                You will have to use a common identifier, eg:

                 

                give each row in your database an ID.

                 

                 

                then pass that ID value on the button press to a PHP script, which does something like:

                 

                $deleteID = $_POST["delID"];
                
                mysql_query("DELETE FROM exampleTable WHERE ID='$deleteID
                '");
                
                

                 

                maybe check that a row with that ID exists first for verification, then pass back a value indicating if removal was a success or not.

                 

                 

                You can delete on other values, but remember they have to be unique for the database, else you'll run the risk of deleting multiple values.

                 

                Or you could delete on a compound key, depends on the data you're storing in the grid.

                • 5. Re: Inserting Into MYSQL Table Via Air/PHP = Not Allowed?
                  jimmyoneshot Level 1

                  Thanks again for your help my friend. I already have tables set up with unique id values etc and the inputs in my app which will 'feed' the data into the php/mysql aren't editable and are invisible to the user and can only be poplulated by clicking an item in a tilelist which is poulated via the mysql tables and will give the inputs their data so they will all be unique anyway.

                   

                  Cheers.