PDA

View Full Version : Help with passing variables - Please !!!


vosgien
05-14-2002, 07:38 AM
Hi,
If you've been following this thread in "General Help" you would have realised by now that my knowledge of php is limited !
So, this is how it goes :
index.html - has open page.swf embedded, var EcardSelect is declared in frame1
NSN.swf is where the viewer can look at cards in thumbnail and enlarged format, when clicking on a card the var EcardSelect is set.
Ecards.swf is the send files with the variables for ecard/email send function.
I have checked and rechecked my paths - nothing wrong that I can see
When user clicks send this code is called :
on(release){
_root.gotoAndStop(2);
_root.Status = "Sending card - please hold";
_root.getURL("http://www.perverseverse.com/index.php", 0, "GET");
}

This is the error message I get :
Warning: Use of undefined constant date - assumed 'date' in D:\WWWRoot\perverseversecom\www\index.php on line 3

Warning: Undefined variable: EcardSelect in D:\WWWRoot\perverseversecom\www\index.php on line 16

Warning: fopen("http://www.perverseverse.com./dBText/date.txt", "w") - No error in D:\WWWRoot\perverseversecom\www\index.php on line 19

Warning: Supplied argument is not a valid File-Handle resource in D:\WWWRoot\perverseversecom\www\index.php on line 20

Warning: Supplied argument is not a valid File-Handle resource in D:\WWWRoot\perverseversecom\www\index.php on line 21
_level0.Status=Success your Card Has Been Sent!

In short my var EcardSelect is not being passed, no text is appearing in my dBtext file, but the email is being sent.
The attached zip contains my php files

HELP!!! Please

Cheers

Vosgien
here (http://www.perverseverse.com)

IFZen
05-14-2002, 09:21 AM
Hi vosgien,

2 things about your index.php :

- I don't understand your first code line :
$CreateEcard = date;
if date is a variable you need the $ before it. If you want to use the date function then put the () after it. Whatever you need, it seems you build a file name with it and that's what produces most of your warnings. Since your file name is wrong, all the operations you perform with it will fail (fopen, fwrite and fclose).

2 - Your EcardSelect variable is also missing when you do the getURL. Be sure that variable is defined into the mc where you launch the GetURL. Since you use the GET method, Flash will send all the variables that are defined into the mc where you do the GetURL. To know if that variable is sent, check the HTTP server logs (access log). You should find lines targeting your index.php script with all the variables sent by Flash. If your EcardSelect variable is not written into the log then that's the proof that your GetURL action doesn't send that variable. In that case redefine your variable at the right place into your SWF.

Hope it helps and... BZen

vosgien
05-14-2002, 09:32 AM
Hi ifZen

The first line of code should read : $CreateEcard = date(U);
this threw me an error regarding the (U); are you saying it should read : $CreatEcard = date(); or : $CreateEcard = $date();

I'm not sure that I understand the second part of your answer, but, I'm going to try to work it out before begging for calrification

Thanks

Vosgien

IFZen
05-14-2002, 09:45 AM
For the date you should use this :
$CreateEcard = date("U");

For the second part of my message, when you perform a GetURL (or a loadMovie, a loadVariable, ...) with a specified method ("GET" or "POST"), Flash add to the URL all the variables defined into the movie clip where you perform the action. For instance, let's say you have a movie clip called "mc1". in that mc you got three variables called "var1", "var2" and "var3" that contains three diffrent values (0, "blah blah blah" and 1024). If you perform into that mc a GetURL action targeting something like http://www.mysite.com/index.php, with the GET method, Flash will ask to your server for that URL :

http://www.mysite.com/index.php?var1=0&var2=blah blah blah&var3=1024

That's the request your server will receive. So you see that all the variables you want to send have to be defined into mc1. All the other variables defined into your SWF (like on _root or into other mc's) are not sent. May be that's why your variable is not transmitted, if it has been defined elsewhere. In your case the varaibles sent are into the mc that contains the button you're using (or on the _root if that button is placed on stage).

Hope you'll solve your problem,
BZen

vosgien
05-14-2002, 11:31 AM
Hi IFZen,
Well that worked to a degree, the variable is now passed, basically I declared the var in frame one of the mc. where the button sits and changed the code on the button to read :
on(release){
_root.EcardSelect = EcardSelect;
_root.Status = "Sending card - please hold";
_root.getURL("http://www.perverseverse.com/index.php", , "GET");
}

problem now is that when I open the email the following link is attached ( as it should be) :

http://www.perverseverse.com/SelectCard.php?EcardText=1021370204&ENum=
However after Num= should be the card number which is the variable EcardSelect. This implies to me that index.php is not talking to CreateCard.php.
You said in your original response that my file name was wrong can you explain what you mean by that as I am still getting the other error messages.

Thanks again,

Vosgien