Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 22nd, 2004, 01:13 AM
Authorized User
 
Join Date: Jun 2004
Location: , , .
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,


Reply With Quote
  #2 (permalink)  
Old July 22nd, 2004, 06:48 AM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
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
::::::::::::::::::::::::::::::::::::::::::
Reply With Quote
  #3 (permalink)  
Old July 22nd, 2004, 09:04 PM
Authorized User
 
Join Date: Jun 2004
Location: , , .
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you,
It works now.

Reply With Quote
  #4 (permalink)  
Old July 10th, 2006, 07:09 AM
Registered User
 
Join Date: Jul 2006
Location: , , .
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

Reply With Quote
  #5 (permalink)  
Old July 14th, 2006, 09:07 AM
Registered User
 
Join Date: Jul 2006
Location: , , .
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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 08:10 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.