Connecting Tech Pros Worldwide Help | Site Map

View, Edit and Update data in MySql!

Newbie
 
Join Date: May 2009
Posts: 5
#1: May 24 '09
Hi,

I was hoping someone could help me with this...

I've set up a database that Flash communicates with through php. I can write to the db and view the information held in it.

What I'm trying to do is view the data in an input text field (this works fine) and then if I edit the text, it will then update the db with the new info, overwriting the old data.

Does that sound feasible or should I look for a different approach!

Many thanks!
Member
 
Join Date: May 2009
Posts: 81
#2: May 26 '09

re: View, Edit and Update data in MySql!


I'm not sure I get everything you said, but you can easily form queues to an SQL server using POST or GET vars.

For example, you can have your code like this:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if(!isset($_GET['action'])) die("No action set.");
  3.  
  4. switch($_GET['action'])
  5. {
  6.      case "update":
  7.           $query = "UPDATE table SET somerow={$_GET['var1']} WHERE id={$_GET['id']}";
  8.           .......................
  9. }
  10. ?>
Then, you can update a row by simply requesting an URL like this: http://myserver/myscript.php?action=...&var1=sometext
This is easily doable in AS using flash.net.URLRequest

However, security can be pretty tough issue when accessing databases like this. You would have to consider any possible of input that could be sent to the said script. For example, the above code is vulnerable to being hijacked through a simple SQL injection.
Newbie
 
Join Date: May 2009
Posts: 5
#3: May 26 '09

re: View, Edit and Update data in MySql!


Thanks for that. I'll try it out! Much appreciated.
Reply