Skip to content
Advertisement

Cannot connect database to heroku with PHP

I am not able to connect my database(.sql) file to heroku. I am using PHP for connecting database and frontend of webpage. The heroku page is showing the static site and for login page, it’s showing error while registering new user. It’s working perfectly fine when I run it on xampp server.

On clicking submit button of a form on heroku deployed app page, it says “herokuapp.com can’t currently handle this request.”.

Here’s the link to my website https://enigmatic-journey-04762.herokuapp.com/login.html

Can someone tell me the steps of deploying php site on heroku using postgresql…..

Like this is the code I’m using for connection using PHP

JavaScript

Advertisement

Answer

This is what i did to connect to heroku postgresql. Change all mysqli functions in the php to PDO functions so that they work with postgresql as well as mysql also.

Open the .sql file and file queries that start with CREATE and remove ‘ ` ‘ this character For eg Something like this

JavaScript

should be changed to this

JavaScript

and paste it to the heroku postgresql console and run it

Use pgweb for a phpmyadmin like interface for postgresql. Get the credentials to connect to the postgresql server in the heroku dashboard

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement