Jump to content

getting HTTP 500 error with include


rwigs

Recommended Posts

When I have the following line in my php file I only get HTTP 500 error when trying to view the page:

require_once('dbConnection.php');

The contents of dbConnection.php are:

<?php
/* Database connection information */
$gaSql['user']       = "myuser";
$gaSql['password']   = "mypassword";
$gaSql['db']         = "mydatabase";
$gaSql['server']     = "localhost";

$db_conx =  mysqli_connect( $gaSql['server'], $gaSql['user'], $gaSql['password'],$gaSql['db']  ) or
        die( 'Could not open connection to server' );
// Evaluate the connection
if (mysqli_connect_errno()) {
    echo mysqli_connect_error();
    exit();
} 

?>

If I comment out the require_once line then the page works (well, it won't do the database connection parts, but I get the form and not HTTP 500.

 

Any reason why this shouldn't work?

 

Link to comment
https://forums.phpfreaks.com/topic/296451-getting-http-500-error-with-include/
Share on other sites

To see why you are getting that error enable error reporting/display errors with the following two lines at the top of your code

ini_set('display_errors', 1);
error_reporting(E_ALL);

The other way to find out the error message is to check your servers error logs.

Thanks! The simplest things... I hadn't thought to check error logs because I didn't really know how to check them on local machine. But I found them and found that I had an undefined class in index.php.

 

That fixes one problem, now on to the next (which I will make a new post for).

 

Thanks again!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.