0

I set up a server on a VM I have running in college. I have phpmyadmin working and I can access my database remotely. I also have a test.php script which contains phpinfo() which works happily enough.

When I try to run any of my other scripts I get an internal server error. I have no idea whats wrong as I copied the scripts which I had working on my local computer exactly over.

Does anybody know any commands or steps I can take to isolate the problem?

Edit Here is the script I am trying to run

<?php
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
include('db_config.php');
mysql_connect(DB_SERVER,DB_USER,DB_PASSWORD) or die(mysql_error())
$db = mysql_select_db(DB_DATABASE) or die(mysql_error()) or die(mysql_error())
?>
Jon Seigel
  • 12,251
  • 8
  • 58
  • 92
TomSelleck
  • 6,706
  • 22
  • 82
  • 151
  • Check the web-server error log and enable error display at the top of your script. – jeroen Mar 08 '13 at 18:00
  • What does the error log say? A 500 error is *always* accompanied by a message in the error log telling you what went wrong. – DaveRandom Mar 08 '13 at 18:00
  • @jeroen Error log first, runtime modification of error reporting directives doesn't help with compile-time errors (which I'm guessing is what this is, my magic 8-ball is putting its money on 5.2 vs. 5.3 syntax). – DaveRandom Mar 08 '13 at 18:01
  • A *500 Internal Sever Error* is ***always*** an invitation to look into the servers error log. It contains more information. As this is PHP, it's also highly likely that it is because of a *Fatal Error in PHP*, so ensuring that PHP error logging is enabled and looking into the PHP error log is very useful, too. [More about the 500 Internal Server Error](http://stackoverflow.com/a/13940190/367456) – hakre Mar 08 '13 at 18:04
  • @DaveRandom True, but many people seem have problems getting to the error log and lots of errors will be displayed. Changed it to **and** anyway :-) – jeroen Mar 08 '13 at 18:04
  • Updated with script, I'll check the error log now – TomSelleck Mar 08 '13 at 18:05
  • @jeroen I would very much hope that `I set up a server on a VM` means that is not the case, but it's a fair point. – DaveRandom Mar 08 '13 at 18:05
  • My guess: `mysql_connect` causes a fatal error because the function does not exists. Likely the mysql extension is not enabled. – hakre Mar 08 '13 at 18:06
  • @DaveRandom I set up a server on a VM hosted in college? – TomSelleck Mar 08 '13 at 18:10
  • @Tomcelic I was merely saying that because you set up a VM you presumably do have access to all the relevant log files. The problem that some users run into that their hosts (usually in shared environments) do not provide access to these logs, but presumably you don't suffer this issue. If you do, get a better host ;-) – DaveRandom Mar 08 '13 at 18:17
  • ohright! Where are the relevant log files? I tried, /var/log/message /var/log/httpd/error_logs The first doesn't have nay helpful information and the second doesn't exist.. – TomSelleck Mar 08 '13 at 18:21
  • 1
    You are not terminating your lines with `;`, and you have a duplicate `or die(mysql_error())` – Terry Mar 08 '13 at 18:48

1 Answers1

0

As Terry pointed out in the comments:

You are not terminating your lines with ; and you have a duplicate or die(mysql_error())

derp!

TomSelleck
  • 6,706
  • 22
  • 82
  • 151