Current location: Hot Scripts Forums » General Web Coding » Flash & ActionScript » [SOLVED] I don't see the fault


[SOLVED] I don't see the fault

Reply
  #1 (permalink)  
Old 02-19-08, 04:38 AM
jonnekke jonnekke is offline
Code Guru
 
Join Date: Oct 2005
Location: holland!
Posts: 706
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] I don't see the fault

Hi there...

what is wrong about this AS? The only way to make it work is to change sendAndLoad to send. .But then a new broswer is opened. That's not what I want..!

ActionScript Code:
  1. emaileen = "mymail@mysite.com";
  2. lvOutt = new LoadVars();
  3. lvInn = new LoadVars();
  4.            
  5. lvOutt.email = emaileen;
  6. lvOutt.format = "h";
  7. lvOutt.sendAndLoad("http://www.url.com/news/sendform.php?formnr=6", lvInn, "POST");

this line of code is in the same script (a bit above the fault part) and is working fine:

ActionScript Code:
  1. lvOut = new LoadVars();
  2. lvIn = new LoadVars();
  3.        
  4. lvOut.action = "geefReactie";
  5. lvOut.email = txt.text;
  6. emaileen = lvOut.email;
  7. lvOut.nrone = dataone;
  8. lvOut.nrtwo = datatwo;     
  9.  
  10. lvOut.sendAndLoad("check.php", lvIn, "POST");

the only difference that I see is:
the url is on another domain in the "fault part" but this shouldn't be a problem is it?..

_j

Last edited by UnrealEd; 02-19-08 at 01:52 PM. Reason: please use the [highlight=ActionScript] wrapper when posting actionscript code
Reply With Quote
  #2 (permalink)  
Old 02-19-08, 05:14 AM
jonnekke jonnekke is offline
Code Guru
 
Join Date: Oct 2005
Location: holland!
Posts: 706
Thanks: 0
Thanked 0 Times in 0 Posts
another wierd thing:

as a test it local from my computer it works fine.. as soon as I
put it on my website it doesn't work..

_j
Reply With Quote
  #3 (permalink)  
Old 02-19-08, 02:02 PM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
the reason why it might not be working is because of a security setting of flash itself. When connecting to a remote host (ip) through the flash application, you need to approve that connection first.

Go to this url:
http://www.macromedia.com/support/do...manager04.html
And select "Add location..." from the "Edit locations" dropdown. Now add that reffers to your swf on your server, and hit "confirm". Refresh your flash application and test it again

Also: are you using the lvInn variable? If not, simply remove it as it is obsolete. You can pass on 2 parameters into the sendAndLoad method (the url, and the method), and it will still work

Just a note: it is best to declare the type of the variable as well. This is done by adding a colon after the name of the variable and then the name of the type. So a LoadVars object declaration should look like this:
ActionScript Code:
  1. var lvOut:LoadVars = new LoadVars();
I'm not sure if this has any advantage, but is defenitely nice when you start creating classes in which you need to declare the fields before you can assign a value to them
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #4 (permalink)  
Old 02-20-08, 04:00 AM
jonnekke jonnekke is offline
Code Guru
 
Join Date: Oct 2005
Location: holland!
Posts: 706
Thanks: 0
Thanked 0 Times in 0 Posts
okay.. it took a looK at the URL.

is this "security" setting is client side.. ? if it is, is there a way to work arround this?.
so that everybody can use swf on my website?..
Reply With Quote
  #5 (permalink)  
Old 02-21-08, 04:03 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
This is indeed a client-side setting. So all visitors will need to approve the application.

I don't know if there's a workaround via flash, but I sure know there's a workaround using php. Instead of submitting the form to http://www.url.com/news/sendform.php?formnr=6, submit it to a page on your server (which is localhost for the flash application), and then submit the form, using php, to http://www.url.com/news/sendform.php?formnr=6. Grab the results, and send them back to flash. It's very easy, since you allready have the mechanism up and running. You just need to create a new page that will send the request to the correct page.
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #6 (permalink)  
Old 02-21-08, 05:35 AM
jonnekke jonnekke is offline
Code Guru
 
Join Date: Oct 2005
Location: holland!
Posts: 706
Thanks: 0
Thanked 0 Times in 0 Posts
okay.. I'll give this a try... do you know how to
submit a form automaticly..
because actually I don't want an extra page to be seen.

So the data should be submitted but the page not changed...

you got what I mean?.

_j
Reply With Quote
  #7 (permalink)  
Old 02-21-08, 08:50 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
yup. It's actually pretty easy. You can either use cURL, or create a socket connection to the http://www.url.com/news/sendform.php?formnr=6 script.

Here's an example on how to do it with cURL:
PHP Code:

$curl curl_init ("http://www.url.com/news/sendform.php?formnr=6");
curl_setopt ($curlCURLOPT_RETURNTRANSFERtrue);
curl_setopt ($curlCURLOPT_POSTtrue);
curl_setopt ($curlCURLOPT_POSTFIELDSsprintf ("email=%s&format=%s"urlencode ($_POST['email']), strval ($_POST['format']));

$results curl_exec ();
curl_close ($curl); 
a socket example:
PHP Code:

$fp = @fsockopen ("www.url.com"80$errNo$errStr15); // never add the http:// protocol in front of the url
if (!$fp) {
  die (
"An error occured: ($errNo$errStr");
} else {
  
$request "POST news/sendform?formnr=6 HTTP/1.1\r\n";
  
$request .= "Host: " $_SERVER['HTTP_HOST'] . "\r\n";
  
$request .= "User-Agent: " $_SERVER['HTTP_USER_AGENT'] . "\r\n";
  
$request .= "Content-Type: application/x-www-form-urlencoded\r\n";
  
$request .= "Content-Legnth: " strlen (sprintf ('email=%s&format=%s'urlencode ($_POST['email']), strval ($_POST['format']))) . "\r\n";
  
$request .= "Connection:close\r\n\r\n";
  if (!@
frwite ($fp$request)) {
    die (
"An error occured");
  } else {
    
$returned NULL;
    while ((
$returned .= fgets ($fp)) !== false);
    
// $returned will hold the returned data from the website.
  
}

__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #8 (permalink)  
Old 02-27-08, 02:29 AM
jonnekke jonnekke is offline
Code Guru
 
Join Date: Oct 2005
Location: holland!
Posts: 706
Thanks: 0
Thanked 0 Times in 0 Posts
shouldn't there be .php in this line?

PHP Code:

$request "POST news/sendform?formnr=6 HTTP/1.1\r\n"
sot that is goes:

PHP Code:

$request "POST news/sendform.php?formnr=6 HTTP/1.1\r\n"
Reply With Quote
  #9 (permalink)  
Old 02-28-08, 06:58 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
Oops, my mistake

Also: you should replace "Content-Legnth" by "Content-Length", another typo
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #10 (permalink)  
Old 02-28-08, 09:38 AM
jonnekke jonnekke is offline
Code Guru
 
Join Date: Oct 2005
Location: holland!
Posts: 706
Thanks: 0
Thanked 0 Times in 0 Posts
this past cause an error:

PHP Code:

if (!$filePointer
{
throw new 
Exception("Chyba spojeni $errorNumber $errorString");

if I delete this part the page is loaded good. What does this part do and what can be the error?..
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Fault tolerance ornoc JavaScript 1 10-17-05 03:02 PM
Anybody know whats wrong NerdRUS PHP 3 01-01-04 11:11 PM


All times are GMT -5. The time now is 06:36 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.