View previous topic :: View next topic |
Author |
Message |
alpay -
Joined: 10 Oct 2005 Posts: 7 Location: New York City
|
Posted: Mon Oct 10, 2005 11:45 am Post subject: my php works w Apache but not Abyss. Undefined Variables... |
|
|
Hi guys, thanks in advance for the help...
I had Apache running on my XP-Pro SP2 box with PHP5.05 and some very simple php was working fine. I stopped the Apache service and installed Abyss to give a try, followed the PHP instructional page here and the same exact php code does not work. I get:
Notice: Undefined index: filla in C:\Program Files\Abyss Web Server\htdocs\testes.php on line 2
I have my php globals on and error reporting is on (E_ALL & ~E_STRICT). what's interesting to me is that the code work on Apache on my machine, and also tested fine on a webhost I have an account with. Any suggestions?
html form:
Quote: | <FORM action="testes.php" method="GET">
<INPUT type="file" name="fn"><BR>
<INPUT type="submit" value="Send">
</FORM> |
php action file:
Quote: | <?php
echo $_FILES['fn']; //just for feedback
$str = $_FILES['fn'];
echo $str; //also for feedback
// the below lines are commented out for simplicity but when uncommented creates a 0kb txt file since no variable seems to be passing through at all, with the echo's also.
//$txtFile="C:fileProcessing.txt";
//$fp = fopen($txtFile,"w");
//fwrite($fp,$str);
//fclose($fp);
//readfile($txtFile);
?> |
Thanks again. _________________ Alpay Kasal
Artist/Engineer
http://www.nycrenderfarm.com |
|
Back to top |
|
 |
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Mon Oct 10, 2005 12:04 pm Post subject: |
|
|
I can't see what caused that exact notice, but to disable notices, set error_reporting to E_ALL & ~E_NOTICE & ~E_STRICT. _________________
 |
|
Back to top |
 |
 |
alpay -
Joined: 10 Oct 2005 Posts: 7 Location: New York City
|
Posted: Mon Oct 10, 2005 12:12 pm Post subject: |
|
|
Thanks for the reply... for now I want to leave notices on so I can fix the problem, I'll turn it off when everything is running smooth.
It looks like the php script simply is not getting the variable from the html form. Should something be different in my php.ini? as of now, it's pretty stock - I simply edited the recommended ini file. _________________ Alpay Kasal
Artist/Engineer
http://www.nycrenderfarm.com |
|
Back to top |
|
 |
MonkeyNation -
Joined: 05 Feb 2005 Posts: 921 Location: Cardiff
|
Posted: Mon Oct 10, 2005 12:28 pm Post subject: |
|
|
A notice isn't an error by any means. Even some of the best commercial software generates a load of notices if you stop it surpressing them.
If the files you're using are exactly the same as below, then that notice is coming from nowhere, "filla" isn't mentioned. _________________
 |
|
Back to top |
 |
 |
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Mon Oct 10, 2005 2:33 pm Post subject: Re: my php works w Apache but not Abyss. Undefined Variables |
|
|
alpay,
The error message you get is generated by PHP and not by Abyss (or Apache). The web server has nothing to do with internal PHP execution.
Apparently, you're using two different installations of PHP which leads to different behaviors.
Are you sure you've updated the correct php.ini file? Which one have you changed? Is it the file that your PHP installation expects (see the output of phpinfo() for a check - phpinfo() dumps the full path of php.ini). _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
 |
roganty -
Joined: 08 Jun 2004 Posts: 357 Location: Bristol, UK
|
Posted: Mon Oct 10, 2005 2:41 pm Post subject: Re: my php works w Apache but not Abyss. Undefined Variables |
|
|
alpay,
i have been creating a image galley script, and have had to include an upload section, and i believe that the problem is in your html form.
below is the revised code, note that in the first <form> tag i have added the attribute "enctype" which, according to http://uk.php.net/features.file-upload is required, i have also changed the "method" type to post.
you also need to have a hidden field with the name "MAX_FILE_SIZE" with a value in bytes of the maximum file upload size. more about this can be read in the link above
Code: | <form action="testes.php" enctype="multipart/form-data" method="post">
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
<input type="file" name="fn" />
<br /><input type="submit" value="Send" />
</form> |
as far as the php file, i cannot see anything wrong with it _________________ Anthony R
Roganty | Links-Links.co.uk |
|
Back to top |
|
 |
alpay -
Joined: 10 Oct 2005 Posts: 7 Location: New York City
|
Posted: Mon Oct 10, 2005 3:33 pm Post subject: |
|
|
Thanks everyone for the help.
monkeynation: I know what you're saying about notices. my concern is that the same script works with Apache and not Abyss with the same PHP installation on the same machine. oh, and my bad with "filla", I copied/pasted the notice while running a different test script - the notice was the same though. substitute filla for "fn" in my post. thanks.
aprelium: as mentioned. php was installed only once, I grabbed it a couple of days ago, it's the latest version, I think I said it was 5.05 (not in front of it right now). I updated the only php.ini that is on the computer, php is installed to C:/php/ which is where the executables and ini is located. I'll double check phpifo() when I'm sitting at that computer but it's the only php installation on a new system.
roganty: do you think your suggestion would apply if I am not doing any uploading? I only need to present the user with the "file browser" window and communicate a filepath to the php script via url encoded variable. Also, I used the "GET" method so that I could see what's going on.
To All: I want to say once again once again (sorry to be a broken record), the path was sent via variable perfectly in Apache. nothing else has changed on the system. both servers are pointing to the same (and only) install folder for php. I am so stumped! _________________ Alpay Kasal
Artist/Engineer
http://www.nycrenderfarm.com |
|
Back to top |
|
 |
roganty -
Joined: 08 Jun 2004 Posts: 357 Location: Bristol, UK
|
Posted: Mon Oct 10, 2005 3:48 pm Post subject: |
|
|
alpay wrote: | roganty: do you think your suggestion would apply if I am not doing any uploading? I only need to present the user with the "file browser" window and communicate a filepath to the php script via url encoded variable. Also, I used the "GET" method so that I could see what's going on. |
This is a quote from the link i gave in my post
php.net wrote: | The MAX_FILE_SIZE hidden field (measured in bytes) must precede the file input field, and its value is the maximum filesize accepted. [...] This form element should always be used as it saves users the trouble of waiting for a big file being transferred only to find that it was too big and the transfer failed. |
the same page also says this:
php.net wrote: | Note: Be sure your file upload form has attribute enctype="multipart/form-data" otherwise the file upload will not work. |
_________________ Anthony R
Roganty | Links-Links.co.uk |
|
Back to top |
|
 |
alpay -
Joined: 10 Oct 2005 Posts: 7 Location: New York City
|
Posted: Mon Oct 10, 2005 4:26 pm Post subject: |
|
|
Roganty: I made the changes you suggested. same deal, still works with apache started. works the same in Abyss when using the "GET" method. when I switched to the "POST" method, the reply from php is simply "Array". does that mean anything to you? thanks again. _________________ Alpay Kasal
Artist/Engineer
http://www.nycrenderfarm.com |
|
Back to top |
|
 |
roganty -
Joined: 08 Jun 2004 Posts: 357 Location: Bristol, UK
|
Posted: Mon Oct 10, 2005 5:01 pm Post subject: |
|
|
alpay wrote: | when I switched to the "POST" method, the reply from php is simply "Array". does that mean anything to you? thanks again. |
It means that it is working now!
the code below loops through the _FILES[] array and displays information on the uploaded file
Code: | <?php
$str = $_FILES;
//one way
foreach( $str as $key=>$value )
print "<br />$key:$value\r\n";
//another way
print "<pre>" .print_r($str, true). "</pre>";
?> |
_________________ Anthony R
Roganty | Links-Links.co.uk |
|
Back to top |
|
 |
alpay -
Joined: 10 Oct 2005 Posts: 7 Location: New York City
|
Posted: Mon Oct 10, 2005 6:04 pm Post subject: |
|
|
Ok, I can stop pulling my hair out... I felt like I was getting nowhere fast so I started from scratch... changed $str=$_FILES to $str=$_REQUEST and everything working as it should now. i know I started this adventure using REQUEST and it didn't work for me, something else must have been broken before.
Roganty, not sure if you understood that I wasn't actually uploading any files, just needed the path. Also, fyi, everything works fine without the newer code additions (ie: MAX_FILE_SIZE)
for all those finding this msg via search in the future, I'll post my working code for your reference.
html file
Quote: | <html><head></head><body bgcolor=#ffffff text=#000000>
<p><FORM action="testes.php" method="POST">
<INPUT type="file" name="filla" /><BR />
<INPUT type="submit" value="Send" />
</FORM> |
php file
Quote: | <?php
// this grabs the url encoded variable, spits it out to a txt file,
// and executes an app with take the variable as a parameter
$str = $_REQUEST['filla'];
$txtFile="C:fileProcessing.txt";
$fp = fopen($txtFile,"w");
fwrite($fp,$str);
fclose($fp);
$command="L:\alpay\clusterscripts\startae.exe $str";
echo $command;
exec($command);
?> |
Thanks for the help guys.. it looks like it was just bad PHP in the end. _________________ Alpay Kasal
Artist/Engineer
http://www.nycrenderfarm.com |
|
Back to top |
|
 |
|