-1

我正在尝试在我的网页上加载不同的内容,但是其中一个$_GET必须有一个空间(因为它是从数据库中调用的)。那么我该怎么做呢?
我没有设置任何链接我正在手动尝试通过 go 转到该页面,?route=1&plantsite=Syncrude+Base+Mine但该页面未加载。

这是我的php:

require_once('config.inc.php');
$gGetRoute = $_GET['route'];
$gGetPlantSite = $_GET['plantsite'];


if ((isset($gGetRoute)) && (isset($gGetPlantSite)) {
  $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_BASE);
  if ($stmt = $mysqli -> prepare("SELECT Latitude, Longitude, Title, Arrival_Time, Direction_Of_Bus, What_Shift FROM Routes WHERE Route_Number = ? AND Plant_Site = ?")) {
    $stmt -> bind_param('ss', $gGetRoute, $gGetPlantSite);
    $stmt -> execute();
    $stmt -> bind_result($gLatitude, $gLongitude, $gTitle, $gArrivalTime, $gDirectionOfBus, $gwhatShift);
  }
}
4

3 回答 3

1

使用urlencode()urldecode()准备用于 GET 的变量

于 2013-03-06T07:59:19.600 回答
0

我认为做事有两种方式:

方式一:

urlencode() //For encoding the URL
urldecode() //For decoding the URL

方式二:

在设置或获取变量之前尝试使用修剪:

 trim($_GET['abc']);

这会使您的多余空间被删除

于 2013-03-06T08:01:55.580 回答
0

利用urldecode()

$gGetRoute = urldecode($_GET['route']);
$gGetPlantSite = urldecode($_GET['plantsite']);
于 2013-03-06T08:31:47.487 回答