Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 22nd, 2004, 01:13 AM
Authorized User
 
Join Date: Jun 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default upload files - Undefined index: DOCUMENT_ROOT

Hello.
I have Windows 2000, PHP4 and IIS.

I tried to run the code from
http://p2p.wrox.com/topic.asp?TOPIC_ID=12104,
but line
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $_SERVER['DOCUMENT_ROOT'].$file_path))

gives error: Undefined index: DOCUMENT_ROOT

I tried recomended echo $_SERVER['DOCUMENT_ROOT'],
and echo $_SERVER['wwwroot'], but it gives undefined index error too.

Please help what to solve undefined index problem.
Thank you,


 
Old July 22nd, 2004, 06:48 AM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

That means that you server doesn't provide that variable, so you need to fill in the path manually or look at phpinfo() for a similar variable.

Since you're using Windows you'd put in something like this.
if (move_uploaded_file($_FILES['userfile']['tmp_name'], "C:\\path\\to\\file\\".$new_file_name))

Regards,
Rich

::::::::::::::::::::::::::::::::::::::::::
The Spicy Peanut Project
http://www.spicypeanut.net
::::::::::::::::::::::::::::::::::::::::::
 
Old July 22nd, 2004, 09:04 PM
Authorized User
 
Join Date: Jun 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you,
It works now.

 
Old July 10th, 2006, 07:09 AM
Registered User
 
Join Date: Jul 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I have suffered the similar problem, running the same config except with php 5.1.4

How would I be able to have my web server to provide that variable, I am using PEAR also with a database abstraction layer.

Also having a problem with this line of code :

// initialize application
$this->app_db_url = $this->setDefault($param['app_db_url'], null);

Returns an Undefined index: REQUEST_URI Error.

Must I specify here the actual Database name or does is it another variable that my server doesn't provide?

Again I recieve the same Error for this line :

function getEnvironment($key)
  {
      return $_SERVER[$key];
  }

How would I write this to overide the Error?

Thanks in advance

 
Old July 14th, 2006, 09:07 AM
Registered User
 
Join Date: Jul 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I'm also having the same problem, It looks as though we are following the same instructions.

To get rid of that error, find :

 $this->getEnvironment('REQUEST_URI'));

and change to

$this->getEnvironment('SCRIPT_NAME'));

Although that doesn't solve the error you get for this line

// initialize application
$this->app_db_url = $this->setDefault($param['app_db_url'], null);

I also need help with this.

Thanks in advance






Similar Threads
Thread Thread Starter Forum Replies Last Post
Notice: Undefined index: username in latinquarter PHP Databases 1 April 18th, 2008 11:37 AM
undefined index and variable p3allen2000 Pro PHP 1 November 1st, 2007 04:49 PM
Undefined index junemo Pro PHP 8 October 31st, 2007 05:45 PM
Undefined Index Error rit01 Beginning PHP 0 March 1st, 2006 10:03 AM
Undefined index ashinotani Beginning PHP 2 August 17th, 2004 03:31 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.