简体   繁体   English

MySQLi Num行以检查行是否存在

[英]MySQLi Num Rows to check if row exist

So used mysqli_num_rows to check if the ID exist. 因此使用mysqli_num_rows来检查ID是否存在。 but now its not even loading up. 但现在它甚至没有加载。 But its crashing my script, not sure what i am missing, or if this just isn't written correctly. 但是它崩溃了我的脚本,不确定我丢失了什么,或者不确定是否编写正确。

Any help would greatly be appreciated. 任何帮助将不胜感激。 some times it takes fresh eyes to see some small errors and i have went over this over and over to find the issue. 有时需要新鲜的眼睛才能看到一些小错误,我已经一遍又一遍地查找问题。

$get_oc = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT id from ap_oc where aff_id=$affiliate_id"));

if (mysqli_num_rows($get_oc) > 0) 
{
    $set_oc = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT commission from ap_oc where aff_id=$affiliate_id"));
    $comission = $set_oc['commission'];

    $get_tl_id = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT tl_id from ap_oc where aff_id=$affiliate_id"));
    $teamleaderid = $get_tl_id['tl_id'];

    $get_tl_oc = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT id from ap_oc where aff_id=$teamleaderid"));

        if (mysqli_num_rows($get_tl_oc) > 0) {
            $set_tl_oc = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT commission from ap_oc where aff_id=$teamleaderid"));
            $t2_comission = $set_tl_oc['commission'];
        } 
}

I accomplished what i needed to do with this code 我完成了此代码所需的工作

   $get_oc = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT id from ap_oc where aff_id=$affiliate_id"));
    $count_oc = $get_oc['id'];
    if($count_oc==''){$count_oc = 0;}
     if ($count_oc > 0) 
        {

for anyone in the future that might have the same issues. 对于将来可能会有相同问题的任何人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM