Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stealthly execute php script 1

Status
Not open for further replies.

ThomasJSmart

Programmer
Sep 16, 2002
634
is there a way to execute a php script in say script.php from within flash without actually opening a window / going to a page with the script?

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
loadVaribles ("script.php", "");

That will execute a script

Regards
David Byng
bd_logo.gif

davidbyng@hotmail.com
 
doesnt seem to be working for what i need it to do...

the php script is to add an entry to a mysql database, the text fields are in flash, im passing the variables thru to the php script with a url_string added to the url like so:

url_string = "?newdate=" add newdate add "&newname=" add newname add "&newmail=" add newmail add "&newmsg=" add newmsg add "&newico=" add newico add "&mcx=" add _root.newx add "&mcy=" add _root.newy add "&reply=0";

but when i do this
loadVariables("addnew.php" add url_string, _root);

nothing gets added to the DB...

thanks,



I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
send then from flash like this

mydata = new loadvars();
mydata.date = newdate;
//and so on

mydata.send("addnew.php",mydata,"POST");

 
thanks :) almost ther,

this works, the entry gets added but the script opens a window to execute the script, this window then asks if it is ok to close the window after it has finished.



I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
Yeah, 'sendandload' is the way to go - 'send' works like getURL and forces a window to open.
 
ah thats useful to know, wangbar. i always use sendandload as i want a message back to say all is well. didnt know that about send.
 
whoohoo! thats wicked many thanks! ***** :)

1 more question if this script is on a frame in the timeline will the swf pause untill the script has completed?

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
cool.

i was trying to do this to load my vars into a mydata object:

// get all needed vars
mydata = new loadvars();
// run php script
mydata.load(notes.php);
if (doc.loaded) {
gotoAndPlay(2);
}
stop();

the notes.php is a mysql connection that gets all data and puts it in a var1=foo&var2=bar etc line.

i had this working fine with loadvariables but i was trying to get it to work with a object.load funtion.

it doesnt seem to be working,
to put the vars into the needed textfields i am using:

thisvar = eval("mydata.var"+c);
set("_root.holder"+c+".content.var", thisvar);

(the c is the loop number that i am using because of a duplicate movie action)

again this worked fine with loadvariables.

would it be better to get it working with object.load or should i just leave it with loadvariables ?

thanks,

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
o never mind i got it working :)

terrible i was getting lazy and jumping to the forum without thinking, tut tut tut :)

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
with loadvars you have to use onload function

mydata.onload = function(){
//what you want to do with the data here
}

there is no need for a loop to detect if variables have been loaded as the onload function is automatically triggered on arrival of the data.
 
how can i get everything to refresh? if i delete an entry and then reload the html-page or go to frame 1 again it wont reload it shows the entry as still ther, even tho it has been removed from the database.

if i close my browser and re-open it works fine, then the deleted entry has been removed.

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
use sendandLoad on the delete button and the new version of the database will be loaded.
 
but i am using a mydata object for all the data to be shown and a deldata object to send the to-be-deleted entry id to the delete script. also the get vars and delete vars are in 2 different php scripts. (not to mention the other functions i have that require a refresh)

i dont see why flash isnt reloading the vars if i tell flash to go to frame 1 in the root which is wher the loadvars script it.

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
ok id still use sendandload

deldata.sendAndload(............);
deldata.onload = function (){
if (success){
//its been deleted
mydata.load(...........);
//force a refresh
}
}

 
nope, its still not doing anything, iv put the whole get variables/duplicateMV/display script into a function on the root, when the movie first starts it playes this function and everything works

and when i delete i have this script:

// make a new object and get all needed vars
//
deldata = new loadvars();
deldata.id = id;
//
// refresh function
//
deldata.onload = function() {
for (c=0; c<=_root.mydata.total; c++) {
removeMovieClip(&quot;_root.holder&quot;+c);
}
_root.loadnotes();
};
//
// run php script
//
deldata.sendAndLoad(&quot;delete.php&quot;, deldata, &quot;POST&quot;);
stop();

loadnotes is the function,

its not working tho, it deletes the entry from the database but flash just goes on showing it.



I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
stick a trace in and make sure loadnotes is being called after a delete.
 
i added
trace(_root.loadnotes);
after the call to the function

it returned [type Function]

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top