I've read this already: Cannot simply use PostgreSQL table name ("relation does not exist")
But I am still having an issue. I am pulling the result of a selection out of a form and passing it over to a PHP script to display the contents of the selected table that already exists in the database.
Error: Warning: pg_query(): Query failed: ERROR: relation "public.msysqueries1" does not exist LINE 1: SELECT * FROM public.MSysQueries1; ^ in C:\xampp\htdocs\phpTest\showTable.php on line 12
No matter what way I use quotes, escape the string, or not, it's forcing the name of the table to lowercase in the actual query, even though it's formatted properly in the string. I've echo'd out the string that's coming in from the form, and it's formatting matches the cases of the table name in PostgreSQL...How do I get PHP to stop forcing it to lower case?
$whatever = $_POST['tableID'];
$table2string = (string)"$whatever";
$escapedTable = pg_escape_string($table2string);
$db = pg_connect("host=localhost port=5432 dbname=name user=user password=password");
$query = "SELECT * FROM public." . "$escapedTable" . ";";
$result = pg_query($db, $query);