Jump to content

getting HTTP 500 error with include


rwigs
Go to solution Solved by requinix,

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
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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.