我正在创建一个表格,该表格根据表单选择输出国家/地区详细信息列表,但我不断收到此错误:MDB2 Error: syntax error
. 如何修复此类错误?
这是我的代码:
<?php
$db =& MDB2::connect($dsn);
if(PEAR::isError($db)){
die($db->getMessage());
}
$table_name="country";
$db->setFetchMode(MDB2_FETCHMODE_ASSOC);
$country_id = mysql_real_escape_string($_GET["country_id"]);
// collect values from a form sent with method=get
$gdp = mysql_real_escape_string($_GET["gdp"]);
$population = mysql_real_escape_string($_GET["population"]);
$country_name = mysql_real_escape_string($_GET["country_name"]);
$gold = mysql_real_escape_string($_GET["gold"]);
$bronze = mysql_real_escape_string($_GET["bronze"]);
$silver = mysql_real_escape_string($_GET["silver"]);
$total = mysql_real_escape_string($_GET["total"]);
$sql = "SELECT * FROM $country WHERE country_id='$country_id'";
$res =& $db->query($sql); //MDB2 Error: syntax error
if (PEAR::isError($res)) {
die($res->getMessage()); //error printed here
}
?>