PDA

View Full Version : error message 405 problem


Julia
01-27-2005, 04:53 PM
Day 1 in starting to learn to integrate Flash and PHP so starting with the tutorial 89: Introduction to Flash and PHP.

Have eventually managed to get the php elements installed on my machine (PC running XP) and working despite the best efforts of my firewall to put a stop to that and now turn back to the tutorial looking forward to making progress.....

I have the flash file with an input box, instance years and a button instance myBtn as requested and this code on the first frame. I am working in MX.


//=================================
// INIT
//=================================
path = "../php/"; //declare path to php files
lvOut = new LoadVars(); //create lv object

//=================================
// BTN CODE
//=================================
myBtn.onRelease = function(){
//assign user-input value to lv property called years
lvOut.years = years.text;
//send to a blank window
lvOut.send(path + "dogyears.php","_blank");

};


I also have a dogyears.php in a separate directory called php with this code:


<?
$calculation= $_POST['years']*7;
echo $calculation;
?>


Now when I go via localhost you are supposed to input a number in the box in Flash and on pressing the button you get another html window generated displaying that number multiplied by 7.

However, instead I get the Error Message 405:
Method Not Allowed
The requested method POST is not allowed for the URL /public/htdocs/nwjv/php/dogyears.php.

Can anyone throw some light on where I am going wrong? I have been through the tutorial a number of times and am sure that I am following the same methods!! Please accept apologies if this is very simple and stupid- this is day 1!!!

Laguana
01-27-2005, 10:42 PM
I'm not entirely sure about this, but i've certainly heard that XP is quite strict with lots of things, and "Method not allowed" sounds like a security thing. You might have to change a security setting, but don't quote me on that, it's just an idea.

Julia
01-28-2005, 11:30 AM
Thanks very much for that - searched on Microsoft and found a reported bug (I know - everyone hates Microsoft!), downloaded latest service pack and it seems to be sorted. Plus - dim moment - had saved the php file incorrectly which certainly wasn't helping matters!

However, my flash file is now bringing up the php file in a new window fine, without any error messages, but the php file is just blank - its not displaying the years x 7 as it supposed to.

Been through the tutorial again and can't see that the coding in the last post is incorrect - my only difference is to reflect the slightly different path I have to the files and its opening the php file so they must be OK.
Would be VERY grateful if anyone can direct me as to where I am going wrong!!

freddycodes
01-28-2005, 04:49 PM
Well one thing you are using send() which will send the request to a new _blank window. I assume this is what you want?

Also you are not specifying a request type either POST or GET, so its GET by default. in your php script, you are trying to access a POST variable which of course does not exist.

Try


<?php
$calculation= $_GET['years']*7;
echo $calculation;
?>


Or for even more debugging, try


<pre>
<?php
var_dump($_GET);
?>
</pre>

Julia
01-31-2005, 02:48 PM
Thanks a million for your help.

Yes I am trying to send this to an new window.

When you say, "Also you are not specifying a request type either POST or GET, so its GET by default. in your php script, you are trying to access a POST variable which of course does not exist."
Are you saying that the POST or GET should be specified in the Flash - it seems to be specified in the php?

Unfortunately I am working in MX, and although the tutorial specifies MX, I can only assume that the zipped files were not produced in this as they will not open on my machine so that I can analyse how it should be done!!!

Ultimately I want to be able to make a Flash movie with thumbnails of images embedded in part of my html page able to load different pieces of text describing those thumbnails. I could easily do this within Flash on its own, I could do this using Flash and HTML if I employ frames. However I would really like to avoid frames but have the text in the HTML part of the page for Accessibility etc. It seems to me that this should be possible, loading the text as variables according to commands produced in the Flash. Hence the foray into php .... although this seems an increasingly tall order for a simple designer! I am getting on fine with actionscript, but this may be delving very deep into the mysterious world of the programmer! Determination may still win!

freddycodes
01-31-2005, 04:34 PM
You are really close, GET or POST is a request protocol. So the requestor would be specifiying the request type.

The third argument to LoadVars.send() is the request type.

lvOut.send(path + "dogyears.php","_blank", "GET");

or

lvOut.send(path + "dogyears.php","_blank", "POST");


Omitting it leaves it to its default which is GET.

Julia
02-01-2005, 01:04 PM
Many thanks for the explanation - it has enabled me to finish this tutorial successfully and gain a better understanding.

Onwards and upwards!