I am using Heroku to deploy my postgresql database project. The site I created using PHP, HTML5 and CSS works fine on localhost with phpmyadmin and the equivalent MySQL database. But, when I transferred it over to Heroku only the SELECT queries work (inserts, updates, and deletes are no good).
The only changes from my localhost to heroku site lie in my .env and file to create the php data object which I pasted below. Can anyone tell me where to look next to solve this issue? Heroku error logs don't show any error. I'm using pgAdmin4 for the postgres db.
.env file
DATABASE_URL="pgsql://postgres:mypassword@localhost:5432/dbname"
other file
require __DIR__ . '/vendor/autoload.php';
$dbopts = parse_url(getenv('DATABASE_URL'));
$dbopts["path"] = ltrim($dbopts["path"], "/");
$db = new PDO("pgsql:" . sprintf(
"host=%s;port=%s;user=%s;password=%s;dbname=%s",
$dbopts["host"],
$dbopts["port"],
$dbopts["user"],
$dbopts["pass"],
ltrim($dbopts["path"], "/")
));
sprintf(), so you can easily echo it. Would you show us what is in it, minus any security-sensitive info? (Don't assume what's in it - check what it actually resolves to in PHP).getenv('DATABASE_URL')into the connection string directly?ltrim($dbopts["path"], "/")twice too - is that deliberate?