0
我想在結果頁面中執行查詢,選擇比索引頁面中的表單數據傳遞更大的信息。邏輯錯誤或語法錯誤?
從索引頁傳遞的值是正確的,其爲如下所示:
Array
(
[device] => sim only
[provider1] => umobile
[plantype] => postpaid
[dusage] => 3
[cusage] => 0
[musage] => 300
)
,但並不如預期我的結果表明。我不知道是我的邏輯錯誤還是我的語法錯誤?
這裏是我的查詢代碼:
<?php
//$planquery="SELECT * FROM plan";
$dquery= "SELECT * FROM details";
$device = $_POST['device'];
$provider1 = $_POST['provider1'];
//$provider2 = $_POST['provider2'];
//$provider3 = $_POST['provider3'];
//$provider4 = $_POST['provider4'];
$plantype = $_POST['plantype'];
$dusage = $_POST['dusage'];
$cusage = $_POST['cusage'];
$musage = $_POST['musage'];
$planquery="SELECT * FROM plan WHERE
Phone='$device' AND SIMTYPE='$plantype' AND 'DATA'>='$dusage' AND 'CALL'>='$cusage' AND 'MSG'>='$musage' ";
$planresult=mysql_query($planquery) or die ("Query to get data from firsttable failed: ".mysql_error());
$dresult=mysql_query($dquery) or die ("Query to get data from firsttable failed: ".mysql_error());
//$sresult=mysql_query($squery) or die ("Query to get data from firsttable failed: ".mysql_error());
while ((($prow = mysql_fetch_assoc($planresult))) && ($drow = mysql_fetch_assoc($dresult))) {
?>
我有兩個細節是
- 500免費味精
- 200免費味精
表單數據包含用戶搜索要求,以防用戶搜索500msg。我想要做的查詢只是選擇'MSG'> ='$ musage'還有其他要求的記錄。這兩個結果都顯示爲結果;這是不符合預期的。
警告mysql_query,mysql_fetch_array,mysql_connect等擴展在PHP 5.5.0中被棄用,並且在PHP 7.0.0中被刪除。相反,應該使用MySQLi或PDO_MySQL擴展。 – Melchizedek
@Glide表示我必須將我的代碼更改爲PDO_MySQL擴展? –
是但是,這不是解決您的問題,這只是爲了防止SQL注入 – Melchizedek