Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

New WordPress Site: "headers already sent" Errors

Greetings All!

I've been following the Learn WordPress/How to Install WordPress on Your Computer track. I've installed Desktop Server on a Win7 machine, and then installed WP. When I enter the URL http://wpdemo.dev/wp-login.php into either of my browsers (Chome or IE), I get the following errors:

( ! ) Notice: Trying to get property of non-object in C:\xampplite\php\ds_runtime.php on line 116 Call Stack

Number Function Location

  1. {main}( ) ..\prepend.php:0
  2. require_once( 'C:\xampplite\php\ds_runtime.php' ) ..\prepend.php:3
  3. DS_Runtime->processPrepends( ) ..\ds_runtime.php:210

( ! ) Warning: Invalid argument supplied for foreach() in C:\xampplite\php\ds_runtime.php on line 116 Call Stack

Number Time Memory Function Location

  1. 0.0020 133864 {main}( ) ..\prepend.php:0
  2. 0.0030 167432 require_once( 'C:\xampplite\php\ds_runtime.php' ) ..\prepend.php:3
  3. 0.0040 168456 DS_Runtime->processPrepends( ) ..\ds_runtime.php:210

[There are many iterations of the above errors.]

( ! ) Warning: Cannot modify header information - headers already sent by (output started at C:\xampplite\php\ds_runtime.php:116) in D:\Users\Rookie\Documents\Websites\wpdemo.dev\wp-login.php on line 390 Call Stack

Number Time Memory Function Location

  1. 0.0690 334192 {main}( ) ..\wp-login.php:0
  2. 0.2240 12827360 header ( ) ..\wp-login.php:390

( ! ) Warning: Cannot modify header information - headers already sent by (output started at C:\xampplite\php\ds_runtime.php:116) in D:\Users\Rookie\Documents\Websites\wpdemo.dev\wp-login.php on line 403 Call Stack

Number Time Memory Function Location

  1. 0.0690 334192 {main}( ) ..\wp-login.php:0
  2. 0.2260 12827968 setcookie ( ) ..\wp-login.php:403

I'm new to PHP, but have started using Notepad++ to get me by (until I get going on PHPStorm) to review the likely culprits, such as ds_runtime.php, prepend.php, wp-login.php and others. I've reviewed file permissions, looked for white spaces, syntax problems, matching brackets and matching <?php & ?>. I've started studying into the foreach construct and arrays, but haven't resolved this yet.

I was hoping to launch into PHP after getting familiar with WP, but this showstopper has kind of rearranged my priorities.

3 Answers

I've never seen that type of error before, but you may want to talk a look at this thread, and maybe it can help:

WP error fix

Thanks, Jacob, I'll keep studying that thread. The first foreach construct below is the offending line 116:

''' php public function processPrepends() { for ( $n = 0; $n <= 10; $n++ ) { foreach ( $this->preferences->{'ds-plugins'} as $name => $file ) { $file = str_replace( "\", '/', $file ); $prepend = $this->delRightMost( $file, '/' ) . '/prepend'; if ( file_exists( $prepend . '' . $n . '.php' ) ) { array_push( $this->prepends, $prepend . '' . $n . '.php' ); } if ( $n === 5 && file_exists( $prepend . '.php' ) ) { array_push( $this->prepends, $prepend . '.php' ); } } } foreach( $this->prepends as $prepend ) { include_once( $prepend ); } } '''

if you know PHP I would say have fun and fix this issue, but I would go ahead and start your local server and download WP again, and see what happens. this code looks like WP core, and its going to take a long time to fix. If it occurs on your second install, then I would investigate.

Yes, that function is in ds_runtime.php. A reinstall sounds good. I could also try another machine.

Yes. have your local up and running, and make sure the your install is in the right place, and you should be fine.

I removed the old website and removed the main Desktop Server folder on drive c: (but didn't uninstall it). I then re-extracted everything from the dsl-win-v382.zip file. Set all the permissions to wide open for all files in that extracted folder, and did a manual install. I created a new website and opened up all the permissions (for myself) for that directory (I wouldn't normally do this). Got the same errors. So now I'll try on a Win10 machine, but I would rather get the Win7 machine running WP.

No errors running on another machine. I'd still like to fix the machine specific errors, though. At least I can continue on in the WP track for now. Thanks for your help, Jacob.

Not a problem, I would suggest you google search wordpress and win 7, maybe there is something you need to do per the machine? don't know, but I'm glad you're up and running.