-
Sending a var to php
this.createEmptyMovieClip ("image_mc", 1);
image_mc._x = -50;
image_mc._y = -50;
myPic = new LoadVars ();
myPic.onLoad = function () {
memberText.text = this.member1name;
image_mc.loadMovie (this.member1pic);
};
myPic.load ("http://blah/members_select.php");
basic the following actionscript show up a pic and some txt
what i want to do is send the variable thats memberText.text to another php script
i've got a button with the intances name "send_var1"
so basically
send_var1.onRelease = function () {
// this sends the vaule of memberText.text to a php script
this is the bit i am stuck on
-
Senior Member
code:
myVarsSend = new LoadVars();
myVarsSend.someVariableName = memberText.text; // something to send to PHP
myVarsRecieve = new LoadVars();
myVarsRecieve.onLoad = function(success) {
if (success) {
// a response was recieved from PHP
}
};
myVarsSend.sendAndLoad("http://www.yoursite.com/somephpscript.php", myVarsRecieve, "POST");
-
same type of problem but something a bit different
Code:
myVarsSend.someVariableName = another.variable;
the another.variable value is in a mysql date format
so what i think is happening is that
PHP Code:
someVariableName = 2003-07-11;
which cause a maths expression
what i need is string
PHP Code:
someVariableName = "2003-07-11";
is possible to make the variable to be sent as string?
-
Senior Member
myVarsSend.someVariableName = another.variable.toString(); ?
-
this problem seems to be doing my head in, thought of a new plan of attack but it doesnt appear work either, i've done the remote debugger and the mysql query isnt working.
i think i can test it but i need to ammend this
code:
on (release) {
sendVars = new LoadVars();
sendVars.inputid = myNews.id1;// CODE CHANGED HERE
sendVars.onLoad = function() {
gotoAndStop(2);
};
sendVars.sendAndLoad('news_show.php', sendVars);
}
so that it actully opens php and i see what vaule is being sent to query
-
Senior Member
If you want to see what is being recieved by PHP (and look at the PHP output) try using the send method instead of sendAndLoad
sendVars.send("news_show.php", "_blank","POST"); // use get or post as appropriate for you script
this will open the PHP script in a blank window so you can see what it is outputting,
in the PHP you can also add the code,
PHP Code:
while (list($name, $value) = each($_POST)) {
echo "<p>$name = $value</p>";
}
to view the variables recieved by PHP.
-
very odd
PHP Code:
$query = "SELECT * FROM news WHERE ('id = $inputid')";
$result = mysql_query($query,$link_id) or die ("Query failed");
$data = mysql_fetch_row($result);
$date = $data[1];
$title = $data[2];
$txt = $data[3];
echo "$inputid<br>";
echo "&date=$date";
echo "&title=$title";
echo "&txt=$txt";
http://www.cakemixcartel.com/scripts/interface.html
see for yourself only the top button has any actionscript on it
value gets sent but the query fails
-
Senior Member
maybe try using the query,
$query = "SELECT * FROM news WHERE id = '$inputid'";
-
if your girl i'd kiss you
Thank you very much
you saved hours of messing around
-
nearly coming the end on this now
on a MC on one frame i have a few buttons that does this
code:
on (release) {
sendVars2 = new LoadVars();
sendVars2.inputname = myName.member2name
sendVars2.onLoad = function() {
gotoAndStop(2);
};
//sendVars2.send('member_show.php','_blank','POST');
sendVars2.sendAndLoad('member_show.php', sendVars2);
}
which works fine this just does a mysql query for inputname
on the next frame i've got
code:
stop();
name.text = sendVars2.name;
surname.text = sendVars2.surname;
djname.text = sendVars2.djname;
myBio = new LoadVars ();
myBio.onLoad = function () {
biography.text = myBio.biotxt;
}
myBio.load ("sendVars2.bio"); // where sendVars2.bio is a url to a txt file
for some reason the sendVar2.bio as the url doesnt work
do i need to declare this before in the first lot of variables?
any hints on where i've gone wrong?
-
The Definition of...
I don't know much of anything about PHP, can i store an array using it? i want to save files to my server from my music mixer. Right now it uses shared objects, but I want to be able to hear other users mixes, and them to hear mine when i get the mixer fully complete.
edit....
Nevermind, I just remembered my server doesn't have php, i have to find a way with cgi/perl, any suggestions anyway would be helpful.
L. Jones
www.urbansory.com
-
Senior Member
Should that be
myBio.load(sendVars2.bio);
without the " " around it?
-
last request for help and then i am done
code:
on (release) {
sendVars2 = new LoadVars();
sendVars2.inputname = myName.member2name
sendVars2.onLoad = function() {
gotoAndStop(2);
};
//sendVars2.send('member_show.php','_blank','POST');
sendVars2.sendAndLoad('member_show.php', sendVars2);
}
thats the mysql query
works fine
right the on the next frame i want to display all the data from that the query
all but one of the sendVars2 works, i am trying to get a jpg to load from the sendVars2.pic variable which is just a url
code: this.createEmptyMovieCLip("pic_mc",1);
pic_mc._x= -260;
pic_mc._y= -150;
this.onLoad = function() {
pic_mc.loadMovie(sendVars2.pic)
}
the movie loads but there is nothing in the pic_mc
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|