-2

I have tried out displaying a simple PHP page with Webmatrix 2 (PHP 5.3 and 5.4), I run into the Internal server error 500.

I also have XAMPP installed (PHP 5.3) and I put my cakePHP application in htdocs folder, the rest of settings is left default. But I also run into the Internal Server Error 500.

Why 500 ? not 800, 1000 ? I see 500 in both cases. I know it is a predefined error. I am not sad at all realizing that. I don't know what to do now, sorry I am a web development novice.

Amelia
  • 2,967
  • 2
  • 24
  • 39
  • 1
    500 error means you must go and look in the web server's error log. The details will be there. – Michael Berkowski Feb 18 '13 at 19:23
  • Likely though, it is a PHP error, and you can enable error reporting on screen with `ini_set('display_errors', 1); error_reporting(E_ALL);` at the top of the PHP script. – Michael Berkowski Feb 18 '13 at 19:24
  • Try setting error reporting settings in php.ini – markasoftware Feb 18 '13 at 19:24
  • **What I said above about 500** is not a complaint. it is a correct acceptable error but I am definitely not accepting it. Things are predefined to me clearly and not seemingly at all. – You Kobayashi Feb 18 '13 at 19:30
  • 1. Is XAMPP running? 2. How are you approaching your index.php? C:\XAMP\htdocs (or whatever destination you installed it or did you enter localhost in your address bar) – Michael Koelewijn Feb 18 '13 at 19:26
  • Yes, in XAMPP case, localhost is setup and page runs fine until I put an application `myapplication` in `htdocs` and try to bring it up from `http://localhost/myapplication`. In IIS vs Webmatrix, it fails from the startup with that error. I have checked config files `(applicationhost.config)` in both `%USERPROFILE%\Documents\IISExpress\config` and `%windir%\system32\inetsrv\config`, and foundthat they are the same. – You Kobayashi Feb 18 '13 at 19:39

1 Answers1

2

A 500 internal error is a 500 internal error.

If an exception is being thrown, catch it. If there is an error in the code, look in the error log and fix it. 500 means there is an error, and PHP refused to continue. This is the generic "oops" error from PHP, and is what the front-facing side of PHP always sends. It would be a security risk in some cases to display all errors to people who visit a website.

To display the specific errors, either look in the logfile for your webserver, or add this snippet to the top of the php files:

<?php
    ini_set('display_errors', 1);
    error_reporting(E_ALL | E_STRICT); // E_STRICT should technically be used too
?>

Remember to remove this snippet on a production site.

Common errors in PHP usually involve invalid T_STRING or T_VARIABLEs, or a Syntax Error. Check string concats, quotes, semi-colons, etc.

As for CakePHP erroring, you probably have an older version of CakePHP, with a strict setting in your inifile that causes a fatal error on E_DEPRECATED.

The current version of CakePHP is 2.3. You should probably update. As far as I know, CakePHP 1.2 still uses new by reference

Community
  • 1
  • 1
Amelia
  • 2,967
  • 2
  • 24
  • 39
  • Oh, thank you man! Server errors are caused mostly by server config and database setup, I have issues with server, php scripts are left untouched, because the scripts need the server at first to bring them up and have themselves interpreted. Settings of php ini or error-reporting won't have any effect at all – You Kobayashi Feb 18 '13 at 19:55
  • @YouKobayashi if your database isn't set up correctly (or the config, for that matter) and you are using a modern database layer/api, then your scripts wont run. – Amelia Feb 18 '13 at 20:00
  • Ok, thank you. my cakephp application was created using old version 1.2.x and my XAMPP php is 5.3.8, which might likely be the cause. – You Kobayashi Feb 18 '13 at 20:21
  • @YouKobayashi it almost definitely is, considering the latest version is 2.3, and wasnt compatible with php5 <= 1.3 – Amelia Feb 18 '13 at 20:24
  • "wasnt compatible with php5 <= 1.3" ? – AD7six Feb 19 '13 at 09:02
  • @AD7six CakePHP 1.1 and 1.2, at the very least, flood the error log with warnings as they use new by reference (`$var = &new class();`). The wording on that comment i wrote was terrible, apologies. – Amelia Feb 19 '13 at 13:12