Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9034447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:28:40+00:00 2026-06-16T08:28:40+00:00

I have used PHP to access MySQL databases numerous times for projects on our

  • 0

I have used PHP to access MySQL databases numerous times for projects on our own server, and always use the same PHP script to do so (changing the login details obviously). However this is my first time using Heroku & ClearDB and I have run into problems.

The DB is on our Heroku PHP app using ClearDB, and I have accessed CLEARDB_DATABASE_URL to find out the username, password, hostname and database name. Just to be sure that I’ve done it correctly, my understanding is that this is the format:

mysql://USER_NAME:PASSWORD@HOST_NAME/DATABASE_NAME?reconnect=true

Using these details in MySQL Workbench I have managed to log into the DB and add a table, so I believe they are the correct details.

However when I try to access it using my PHP script, with the same variables taken from the URL, I get the following error:

HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the request.

At first I thought that maybe the Heroku app had gone done, but I can still access any of the functions in the PHP script that DO NOT attempt to access the database.

As I say, this script has always worked before so I am not sure where the problem lies.
My database connection is in a separate class with the following constructor:

function __construct()
{
    $this->DB_HOST     = 'us-cdbr-east-02.cleardb.com';
    $this->DB_USERNAME = 'the_username_from_url';
    $this->DB_PASSWORD = 'the_password_from_url';
    $this->DB_DATABASE = 'the_database_name_from_url';

}

with a connect() function which is called as needed by other classes:

function connect()
{       
    self::$instance = new mysqli($this->DB_HOST, $this->DB_USERNAME, $this->DB_PASSWORD, $this->DB_DATABASE);

    if (mysqli_connect_errno()) {
        $this->raise_error(printf("Connect failed: %s\n", mysqli_connect_error()));
    }

    return self::$instance;
}

I am 99.9% certain that the problem is caused by attempting to connect to the database. Even though it does not return any PHP error messages when I test the script in a browser, it is only the DB based functions that cause the 500 error.

I’m open to any and all suggestions…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T08:28:43+00:00Added an answer on June 16, 2026 at 8:28 am

    For those with the same issue, I have fixed this but am not 100% sure how, it was 1 of 2 possible things.
    Firstly, I rebuilt my Heroku app using a custom buildpack. At first this didn’t work, so I presumed it was not the answer.
    Then I left the Heroku app for a fortnight…and suddenly it was mySQLi compatible!

    Either the custom buildpack DID work and just needed time to become active, or Heroku made changes at their end which fixed my problem.

    Apologies that I cannot provide a better answer, but as I say the problem was miraculously fixed after leaving the Heroku app for about 2 weeks.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am used to developing in PHP/MySQL and have no experience developing with SQL
I have PHP file where I have defined the server access variables as well
I have an HTML5/Javascript (PHP/MySQL on the server) app with a cache manifest and
I have used PHP array for HTML select, then I put my codes in
I have recently used a PHP pagination tutorial, Pagination - what it is and
Having used PHP GD for some time I have decided to move to Imagemagick.
Tech used: PHP 5.3.10 Hi, I have an array (example below) I need to
I want to get Httpresponse body in php.I have used pear.but it gives me
I used to have PHP websites and using url rewriting on picture to have
I have a database of events that are used to fill a PHP calender.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.