Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / General Flash Topics / July 2008



Tip: Looking for answers? Try searching our database.

[F8] FLASH Writes to PHP/MYSQL. Working, but question on parallel version

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nightkarnation - 02 Jul 2008 01:36 GMT
Ok, Here's the deal:

FLASH CODE:
[B]goal:[/B] write to php the values of the flash dynamic txt's
[I][SIZE="2"](php will send them to mysql, php code later below)[/SIZE][/I]

[CODE]// create the LoadVars Objects
var content_lv:LoadVars = new LoadVars();
btnUpload.onRelease = function() {
    content_lv.action = "write";
    content_lv.name = txtName.text;
    content_lv.email = txtEmail.text;
    content_lv.location = txtLocation.text;
    content_lv.sendAndLoad("http://localhost/Test/read.php", content_lv, "POST");
    txtStatus.text = "Upload Succesful";
};[/CODE]

WORKING PHP CODE:

[PHP]
//write to mysql
$name=$_POST['name'];
$email=$_POST['email'];
$location=$_POST['location'];
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("learning") or die(mysql_error());
mysql_query("INSERT INTO `data` VALUES ('$name', '$email', '$location')");
Print "Your information has been successfully added to the database.";
[/PHP]

Note that the code below that was written in flash...above on the php code its
not being used:
[CODE]content_lv.action = "write";[/CODE]

NOT WORKING PHP CODE:

[PHP]//write to mysql.php
    if ($action == "write")
    {
$name=$_POST['name'];
$email=$_POST['email'];
$location=$_POST['location'];
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("learning") or die(mysql_error());
mysql_query("INSERT INTO `data` VALUES ('$name', '$email', '$location')");
Print "Your information has been successfully added to the database.";
    }[/PHP]

Here u can notice that im trying to get the value "write" from flash, but for
some reason (bad code obviously) php isnt recognizing [B]($action ==
"write")[/B] and obviously nothing happens

Any suggestions??
Looking forward for the solution
Cheers!
Noelbaland - 02 Jul 2008 05:51 GMT
Hello there,

I can see in your PHP script that your not testing (or assigning) your $action
variable.  Test it with the isset command first and then assign it to the
variable (see code below).

Also, since you're using sendAndLoad you should create another LoadVars object
to handle the errors and success values from the server.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.