此查询不起作用

时间:2015-10-31 11:49:31

标签: php

$qurym="SELECT * FROM referal_member WHERE `ref_cusid` = '$id' && `confirm` = '1'";
$resm=mysqli_query($con,$qurym);
$rowm=mysqli_fetch_array($resm);

2 个答案:

答案 0 :(得分:0)

试试这样:[如果字段(ref_cusidconfirm)属于INT类型,则传递值$id1,不带单引号('),否则进行如下更改]

$qurym = "SELECT * FROM referal_member 
          WHERE `ref_cusid` = ' " . $id . "' 
          AND `confirm` = '1'";

$resm = mysqli_query($con,$qurym);
// check query returns something or not
if(mysqli_num_rows($resm)){
 // fetch data 
  $rowm=mysqli_fetch_array($resm);
}
else{
 // no data found
}

答案 1 :(得分:0)

如果是整数数据类型,请从确认中删除引号。

$qurym="SELECT * FROM referal_member WHERE `ref_cusid` = '$id' && `confirm` = 1";
$resm=mysqli_query($con,$qurym);
$rowm=mysqli_fetch_array($resm);
print_r($rowm); // to check results.

或者如果ref_cusid也是整数类型。

$qurym="SELECT * FROM referal_member WHERE `ref_cusid` = $id && `confirm` = 1";
$resm=mysqli_query($con,$qurym);
$rowm=mysqli_fetch_array($resm);
print_r($rowm); // to check results.