Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 06-06-2012, 03:06 PM   #1
HendrikJan
Registered User
 
Join Date: Jun 2012
Posts: 2
Default Passing variables AS2 -> PHP

Hello!

I'm having problems with the upload section of my website.
People can enter the details of a song and upload it.
When it is uploading, a file called appenlist will send the variables to my xmlplaylist.
But when i check my playlist afterwards, the variables are empty.

This is my AS2 code

PHP Code:
var lvSend:LoadVars=new LoadVars();
var 
lvReceive:LoadVars=new LoadVars();    
lvSend.titel tTitel.text;
lvSend.artiest tArtiest.text;
lvSend.genre tGenre.getValue();
lvSend.naam file.name;
lvSend.sendAndLoad("appendlist.php"lvReceive"POST"
;

The added text in my xml playlist looks like this:


PHP Code:
<listitem name='' ''>
<
stream name=''>
</
listitem
Instead of the variables it gives nothing.

My code for receiving the variables in php is this:


PHP Code:
$titel $_POST['titel'];
$artist $_POST['artist'];
$genre $_POST['genre'];
$name $_POST['name']; 

Why are my variables empty? Did something went wrong while passing the variables? When i use tha trace() command, my variables are shown, so i have no idea where it goes wrong.

I'm using WampServer to host my site locally.

Any help is appreciated!
Hendrik-Jan
HendrikJan is offline   Reply With Quote
Old 06-06-2012, 03:13 PM   #2
HendrikJan
Registered User
 
Join Date: Jun 2012
Posts: 2
Default Passing variables AS2 -> PHP

Hello!

I'm having problems with the upload section of my website.
People can enter the details of a song and upload it.
When it is uploading, a file called appenlist will send the variables to my xmlplaylist.
But when i check my playlist afterwards, the variables are empty.

This is my AS2 code

PHP Code:
var lvSend:LoadVars=new LoadVars(); 
var 
lvReceive:LoadVars=new LoadVars();     
lvSend.titel tTitel.text
lvSend.artiest tArtiest.text
lvSend.genre tGenre.getValue(); 
lvSend.naam file.name
lvSend.sendAndLoad("appendlist.php"lvReceive"POST")  

The added text in my xml playlist looks like this:


PHP Code:
<listitem name='' ''
<
stream name=''
</
listitem
Instead of the variables it gives nothing.

My code for receiving the variables in php is this:


PHP Code:
$titel $_POST['titel']; 
$artist $_POST['artist']; 
$genre $_POST['genre']; 
$name $_POST['name']; 
Why are my variables empty? Did something went wrong while passing the variables? When i use tha trace() command, my variables are shown, so i have no idea where it goes wrong.

I'm using WampServer to host my site locally.

Any help is appreciated!
Hendrik-Jan
HendrikJan is offline   Reply With Quote
Old 06-06-2012, 08:56 PM   #3
Raudius
Registered User
 
Join Date: Jun 2012
Posts: 13
Default

I tried your code. It worked fine (for getting variables from AS to PHP) when i used GET instead of POST.

Here is what I used to test it:

PHP:
PHP Code:
<?
$titel 
$_GET['titel'];



$file fopen("test.txt","w");
fwrite($file,"Variable from AS: ".$titel);
fclose($file);

?>
AS2:
ActionScript Code:
on(press){     var lvSend:LoadVars=new LoadVars();     var lvReceive:LoadVars=new LoadVars();          lvSend.titel = tTitel.text;     lvSend.sendAndLoad("test.php", lvReceive, "GET"); }


Hope it works for you,
Raudius.

Last edited by Raudius; 06-06-2012 at 09:08 PM.
Raudius is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:17 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.