Can the server run out of memory?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Can the server run out of memory?

Post by spacebiscuit »

I am using php to user input via a form. When the form is submited it posts the data to itself and then displays it on the next screen for the user to verify. When the user is happy and they hit submit on the verification screen the data is again posted via the form (this time as type hidden) to itself.

On the 3rd and final screen I show a confirmation message and I am opening a new window via a popup. I am posting the data to the new window via variables in the url. In total I am posting 28 variables. On the resulting page I can only aceess the first 15. If I remove variables 1-15 and send only 16-28. So I know my code is correct but why can I not access all of the variables?

Is this a memory issue?

Thanks,

Rob.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

It could be the query string length issue. There's always limit set at the server, usually about 1-4K. If your query string exceeds that limit, you would observe the exact behavior you described.
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Post by spacebiscuit »

So what is the workaround, how can I post 28 variables to an new page?

Rob.
User avatar
Jean-Yves
Forum Contributor
Posts: 148
Joined: Wed Jul 02, 2003 2:13 pm
Location: West Country, UK

Post by Jean-Yves »

Use method="post" rather than method="get" in your form tags.

Then use the $_POST[] array to get at your variables.

HTH.
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Post by spacebiscuit »

I am using method post in my forms.

Then to access the form input I am using :

$zip = $_POST["zip"];

But I cannot use this to to pick up the variables on my popup can I?

Rob.
User avatar
Jean-Yves
Forum Contributor
Posts: 148
Joined: Wed Jul 02, 2003 2:13 pm
Location: West Country, UK

Post by Jean-Yves »

You can use JS to pass the values back to the opening window, and you can then store them in hidden vars or plain text boxes, whichever suits. Then when you submit the form, you can get the vars as you are doing now in PHP.

Unless I've misunderstood what you're trying to achieve?
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Post by spacebiscuit »

i am using a javascript popup window at present, passing the variables in the url. On the popup window I am using this to access the variables:

$zip = $_GET["zip"];

Any other suggestions would be appreciated.

Rob.
User avatar
Jean-Yves
Forum Contributor
Posts: 148
Joined: Wed Jul 02, 2003 2:13 pm
Location: West Country, UK

Post by Jean-Yves »

Hmmm...

Can you post the code that opens the popup and also the code that retrieves the value (as above) including anything that you may come before that line?
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Post by spacebiscuit »

Here is my popup:

Code: Select all

function popjack(printflag){ 

window.open('../waybill/waybill.php?ship_day=<? echo"$ship_day"; ?>
                                   &ship_month=<? echo"$ship_month"; ?>
                                   &ship_year=<? echo"$ship_year"; ?>
                                 &print='+escapeprintflag),'popjack','toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,scrollbar=no,width=650,height=534');

                           }
Then on the popup window:

Code: Select all

$ship_day = $_GET["ship_day"];
$ship_month = $_GET["ship_month"];
$ship_year = $_GET["ship_year"];
As I mentioned I am sending 28 variables. 21 send ok. If I remove number 21 so that what was 22 then becomes 21 it works where as previously it doesn't. So the code is correct.

Rob.
User avatar
Jean-Yves
Forum Contributor
Posts: 148
Joined: Wed Jul 02, 2003 2:13 pm
Location: West Country, UK

Post by Jean-Yves »

Ah! Yes, the original reply was probably correct. I got sidetracked when you mentioned that you were using forms and the post method, which is a different matter altogether.

The querystring is limited in length, so probably you are hitting this limit.

One way around it is to store the values in a session variable instead of the querystring.

Sorry, I was being a little dense there! :?
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Post by spacebiscuit »

The odd thing is that beofre i modified the code to have the middle verification screen the popup with the 28 variables worked perfectyl with no problems.

I then added the 3rd screen and now the problem is occuring.

I tried the sssion variables but they do not work!

Rob.
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Post by spacebiscuit »

the code i have described above is in a file called functions.php which contains a function which I have written called 'waybill'.

The script functions.php is called from another named main.php. Main uses sessions variables. Can I register session variables within the function 'waybill'. At the moment when I do this they do not seem to work.

Rob.
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

u can always do <form action="some_page.php" target="new"> and when you click submit it will auto make a popup window and the post variables will automatically be there in the $_POST array. that would probebly be much easier than manually putting in all the variables in the javascript window.open thing.
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Post by spacebiscuit »

Hi thanks for the reply, if I use that method do I have to send the variables as hidden types within the form?

Rob.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

I'm sure you're hitting the 255 char length limit of the url.

why not just grab the values of the form fields on the pop-up window?

ie:

Code: Select all

&lt;form name=&quote;MyForm&quote;&gt;
&lt;input type=&quote;text&quote; name=&quote;var1&quote;&gt;
&lt;/form&gt;

Code: Select all

&lt;script&gt;
var var1 = opener.document.MyForm.var1.value;
// do whatever you want with var1 now
&lt;/script&gt;
Post Reply