I am new with pdo and php so please bear with me.
What I wanted is to create secure connection with db and get data. But as I checked there is not even db connection. When I inspect element I found this:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
I checked it and I think I know what does it mean, but I could not fix it
here my codes,
global $dbname = $_GET['dbname'];
global $table = $_GET['table'];
global $yerId= $_GET['gid'];
try {
$db = new PDO("pgsql:dbname=$dbname;host=localhost", "postgres", "postgres" );
$sql = $db->query ("SELECT km, turu, hat_kesimi, ili, ilcesi, mahadi FROM $table WHERE gid = $yerId ");
while($result = $sql-> fetch(PDO_FETCH_ASSOC) ) {
printf ('<table><thead><tr><th colspan="4" align="left" >TCDD 3.BOLGE MUDURLUGU <img src="tcdd.png" align="right" width="92px" /></th></tr><tr><th colspan="4">Hemzemin Gecitler ve Ozellikeri</th></tr></thead><tbody><tr><th>Kilometre</th><td colspan="3">%s</td></tr><tr><th>Turu</th><td colspan="3">%s</td></tr><tr><th>Hat Kesimi</th><td colspan="3">%s</td></tr><tr><th>Sehir</th><td colspan="3">%s</td></tr><tr><th>Ilce</th><td colspan="3">%s</td></tr><tr><th>Mahalle</th><td colspan="3">%s</td></tr><tr><th colspan="4" > copyright © all rights reserved by Piri Reis Bilisim </th></tr></tbody></table>', $result["km"],$result["turu"], $result["hat_kesimi"], $result["ili"], $result["ilcesi"],$result["mahadi"]);
}
$dbh = null;
}
catch(PDOException $e)
{
echo $e->getMessage();
}