[英]SQL query does not work when called by window.location.href
當我選擇一個選項時,我會使用onchange函數調用Javascript代碼。 我發送2個參數:
//capaciteit.php
function testfunction(week, id)
{
window.location.href = "capaciteitberekening.php?week=" + week + "&id=" + id;
}
我將文件稱為capaciteitberekening.php並隨其發送參數。 然后我嘗試使用$ _GET函數獲得兩個參數:
//capaciteitberekening.php
require ('capaciteit.php');
$id = $_GET['id'];
$week = $_GET['week'];
echo $id, $week;
在回顯$ id和$ week(檢查它們是否正常工作)之后,我調用一個查詢:
//capaciteitberekening.php
$datumbegin = mysql_query("SELECT * FROM capaciteit");
while($row = mysql_fetch_array($datumbegin))
{
echo $row['DAGEN'];
}
當我在網站上嘗試此操作時,它僅顯示$ id和$ week的回顯。
該代碼是有效的代碼,因為我在其他地方使用了它,並且在這里可以正常工作。
這是我連接到數據庫的方式:
require('auth.php');require_once('config.php');require_once('exec/pubs_exec.php');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); //Database openen
if(!$link) die('Niet gelukt om verbinding te maken met de server: ' . mysql_error());
$db = mysql_select_db(DB_DATABASE); //Select database
if(!$db) die("Selecteren van DB mislukt");
在config.php中,我設置了DB_host,DB_USER,DB_PASSWORD和DB_DATABASE的值
我在這里做錯了什么?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.