我想使用文件zoek_1.sql从表中进行选择;该文件包含:
SELECT *
FROM ds_kort
WHERE
age BETWEEN '$ageMin' AND '$ageMax'
ORDER BY id
我想从文件zoek.php调用此文件。 zoek.php的内容是:
<?php
include_once 'inc/connect.inc';
//defines $con
$ageMin = (int)filter_input(INPUT_POST, 'ageMin', FILTER_SANITIZE_NUMBER_INT);
$ageMax = (int)filter_input(INPUT_POST, 'ageMax', FILTER_SANITIZE_NUMBER_INT);
//the variables $ageMin and $ageMax come from a form
$sql = file_get_contents("zoek_1.sql");
$result = $con->query($sql) or die(mysqli_error($con));
变量$ ageMin和$ ageMax尽管已定义,但似乎没有转移到查询中。该查询将$ ageMin和$ ageMax解释为0。
我正在wampserver上这样做。