-3

I am migrating a php structure onto a new server,

The original test bed at http://www.texility.com/ works quite well, and I have made an identical mySQL structure and have the same php over on a new server at http://www.sequility.com/

But as you can see, there are errors in the PHP all of a sudden.

specifically:

Notice: Undefined variable: settings in /home/sequilit/public_html/index.php on line 58 Warning: Invalid argument supplied for foreach() in /home/sequilit/public_html/index.php on line 58

Warning: Cannot modify header information - headers already sent by (output started at /home/sequilit/public_html/index.php:58) in /home/sequilit/public_html/index.php on line 100

Error: Could not load template /home/sequilit/public_html/app/view/index.php!

I have tried to fix those arrays, but I have a poor understanding of the code as I didn't write it, and a fairly poor understanding of PHP in general, but I am trying to learn as well as I can. If I change the array variable names, the page shows up but nothing works as I imagine other code needs those original variable names.

I have double checked and the php is identical on the test bed even without a /home/sequilit/public_html/app/view/index.php file, could anyone help point me in the right direction to solve this problem? I'm sorry for any lack of explanation that would arise from my naivety in this subject.

Ty Underwood
  • 897
  • 1
  • 6
  • 9
  • 6
    "I have a poor understanding of the code as I didn't write it, and a fairly poor understanding of PHP in general" --- so hire someone then? – zerkms Oct 29 '12 at 02:38
  • 2
    It sounds like you may have stricter `error_reporting` on one server. http://php.net/manual/en/function.error-reporting.php – Matt Whipple Oct 29 '12 at 02:39
  • yeah, hiring would be ideal, but I need a stopgap so I can test CSS, which is my actual area of expertise. – Ty Underwood Oct 29 '12 at 02:39
  • @Ty Underwood: how your current aim (having a stopgap) justifies that? Try to come to some garage and ask people to fix your car for free just because you're a css guy and not a mechanic. – zerkms Oct 29 '12 at 02:41
  • @zerkms I don't understand the hostility, I'm sorry if I am offending you somehow. – Ty Underwood Oct 29 '12 at 02:42
  • @Matt Whipple can I add something to php.ini to turn off error reporting? or does it have to be included on a page? – Ty Underwood Oct 29 '12 at 02:43
  • @Ty Underwood: you didn't offend me personally at all - but this is a programmers community, so we're here to help programmers. People, who are keen in learning how to program. Now we see that you have an issue and haven't even tried to solve it (because it's not your major work area) - so you want someone to do your paid work for you for free. – zerkms Oct 29 '12 at 02:44
  • @zerkms No I didn't explain myself fully. Yes I am a novice, but I am trying to learn more about PHP, though I don't think I am capable of learning fast enough without asking questions about things I can't figure out on my own, like this problem. – Ty Underwood Oct 29 '12 at 02:47
  • @TyUnderwood you should be able to configure it in multiple places. The best bet to start may be an `.htaccess` file assuming you're running Apache. – Matt Whipple Oct 29 '12 at 02:49
  • 2
    possible duplicate of [PHP: "Notice: Undefined variable" and "Notice: Undefined index"](http://stackoverflow.com/questions/4261133/php-notice-undefined-variable-and-notice-undefined-index) – mario Oct 29 '12 at 02:49
  • 2
    possible duplicate of [Headers already sent](http://stackoverflow.com/questions/8028957/headers-already-sent-by-php) – mario Oct 29 '12 at 02:49
  • @Ty Underwood: actually "Notice: Undefined variable: settings" --- this thing is php 101 and should be learnt on the very first day of learning it. So - not sure what you mean by "trying to learn more" – zerkms Oct 29 '12 at 02:50
  • I'm sorry that I was too presumptive @zerkms for you to treat a new user that way. I apologize for not learning things correctly and I will try to do better. – Ty Underwood Oct 29 '12 at 03:00

1 Answers1

2

The difference in environments that you are observing is due to differences in configuration. Particularly in regards to error reporting and output buffering.

You could turn down the error reporting and turn up the output buffering (4096 should do the trick) however the real problem is crappy code. Also note that the first issue (reporting errors) is definitely causing the second issue (headers already sent).

I'd hire a developer or speak to the original author about fixing the issues.

Update

Just to point out the obvious, the code at line 58 of index.php is attempting to use a variable $settings in a foreach loop however $settings has not been defined at that point. You could fix this however my guess is this would only produce further E_NOTICE level errors.

Phil
  • 157,677
  • 23
  • 242
  • 245
  • 2
    "Your issue is due to differences in configuration" --- I wouldn't say so :-) The issue is caused by terrible code at first place. – zerkms Oct 29 '12 at 02:50
  • @zerkms Yeah, changed my original wording – Phil Oct 29 '12 at 02:52
  • Yup, now it's great :-) Don't think I just was looking to find any fault, but **TOO MUCH** people here think that their issues are the result of bad configuration, not just writing stupid code :-) +1 – zerkms Oct 29 '12 at 02:53
  • 1
    @zerkms agreed. I personally think PHP should always run with full error reporting and 0 buffering. The only configurable option should be `display_errors` / `log_errors` – Phil Oct 29 '12 at 02:55
  • Thanks, this really helps. I know what direction to pursue now. – Ty Underwood Oct 29 '12 at 02:59