请您查看以下代码,让我知道如何修复代码的FROM econo WHERE ".$collm."=1") ;";
部分以消除代码错误的禁用其余部分。
我已尝试将"
替换为'
,但这会在代码中禁用我需要的$collm
<?PHP
include 'conconfig.php';
$con = new mysqli(DB_HOST,DB_USER,DB_PASS,DB_NAME);
$collm = $_POST['column'];
$query = "SELECT x, y FROM econo WHERE ".$collm."=1";
$results = $con->query($query);
$return = array();
if($results) {
while($row = $results->fetch_assoc()) {
$return[] = array((float)$row['x'],(float)$row['y']);
}
}
$query2 = "CREATE TEMPORARY TABLE IF NOT EXISTS `charts_econo` (
`id` int(12) NOT NULL AUTO_INCREMENT,
`econo_sum_projects` decimal(12,7) NOT NULL,
`econo_sum_powerline` decimal(12,7) NOT NULL,
`econo_sum_roads` decimal(12,7) NOT NULL,
`econo_sum_cost` decimal(12,7) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AS(SELECT COUNT(project),
SUM(powerline_length),
SUM(road_length),
SUM(cost_per_year)
FROM econo WHERE ".$collm."=1") ;";
$con->query($query2);
$con->close();
echo json_encode($return);
?>
答案 0 :(得分:1)
只需替换:
FROM econo WHERE ".$collm."=1") ;";
使用:
FROM econo WHERE $collm=1";
答案 1 :(得分:0)
来自
FROM econo WHERE ".$collm."=1") ;";
到
FROM econo WHERE ".$collm."=1) ;";
如果你真的想把引号留在那里,那你只有一个太多了。