我是新的pdo和php,請耐心等待。php postgres pdo提取並選擇查詢
我想要的是與db創建安全連接並獲取數據。但是,當我檢查甚至沒有數據庫連接。當我檢查元素,我發現這一點:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
我檢查,我想我知道這是什麼意思,但我不能修復它
我在這裏的代碼,
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();
}
你爲什麼讓使用$ _GET 您的數據庫憑據您的附加您所有的憑據,以您的網址..它是不是一個好的做法加上一個安全漏洞太 – justrohu 2014-09-22 12:05:16
如果遇到500錯誤,請檢查Web服務器的錯誤日誌。通常有一個明確的錯誤信息,詳細說明什麼是錯的。 – 2014-09-22 12:06:19
第一傑拉爾德,現在我沒有得到那個錯誤,但我想要什麼不會發生,代碼沒有錯誤地工作 第二@justrohu,我必須使用get方法 – 2014-09-22 12:15:46