dpndp64206 2019-01-04 07:03
浏览 25

如何将以下信息写入VConnect中的文件?

I am trying to get the following information to be written into a text file and can get it to work in my cPanel but not with VConnect. Have you guys used VConnect before?

I have tried changing the folder's name and have already set the permission to write in my folder called invoice but still can't get it to write in the folder.. everything else is working but just creating the file...

    <?php
include_once 'navbar.php';
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);

if(!isset($_SESSION['u_uid'])) {
    header("Location: index.php?medical_subscriptionplan_process=notlogin");
    exit();
} else {
    include_once 'includes/dbh.php';
    if(isset($_POST['submit'])) {
        $views = strip_tags($_POST['subscriptionplan']);
        $csrf = strip_tags($_POST['token']);

        if (!hash_equals($csrf, $_SESSION['token'])) {
            header("Location: medical_subscriptionplan.php?medical_subscriptionplan_process=wrongtoken");
          exit();
        } else {

        if ($views == '') {
            header("Location: medical_subscriptionplan.php?medical_subscriptionplan_process=emptied");
            exit();
        } else {
            if ($views == '10_views') {
                $subscriptionplan = '10_views';
                $views = 10;
                $token = 'qqewreqreqwsdfdfdafcbvcQERFGHFGHGFHRETERTDF!@#$%^^()';
                $token = str_shuffle($token);
                $token = substr($token, 0, 10);
                $date = date("Y-m-d H:i:s");
                $paidbydate = date("Y-m-d H:i:s", strtotime("+2 day"));
                $fees = 5;

                $sql = "UPDATE memberships
                        SET subscriptionplan = ?, fees = ?, token = ?, enrollment_date = ?,                             paidbydate = ?, views = ?
                        WHERE user_uid = ?;

                       ";
                 $stmt = mysqli_stmt_init($conn);
                        if(!mysqli_stmt_prepare($stmt, $sql)) {
                           echo "SQL error";
                        } else {
                          mysqli_stmt_bind_param($stmt, "sisssis", $subscriptionplan, $fees,                             $token, $date, $paidbydate, $views, $_SESSION['u_uid']);
                          mysqli_stmt_execute($stmt);
                          $result = mysqli_stmt_get_result($stmt);
                          $row = mysqli_fetch_assoc($result);
                          echo $row['subscriptionplan'];
                          echo $row['enrollment_date'];
                          $myfile='invoice/10views'.$_SESSION['u_uid'].'.txt';

                                  if(file_exists($myfile)) {
                                     $invoice = "------------------------------------
"; 
                                $invoice .= "Level 1 Monthly Subscriptionplan Information
"; 
                                $invoice .=  $level1."
"; 
                                $invoice .= "Subscriptionplan:".$row['subscriptionplan']."
"; 
                                $invoice .= "Enrollment Date:".$row['enrollment_date']."
"; 
                                $invoice .= "Fees:".$row['fees']."
"; 
                                $invoice .= "Payment Status:".$row['paid']."
"; 
                                $invoice .= "Expiry Date:".$row['expirydate']."
"; 
                                $invoice .= "Payment Due Date:".$row['paidbydate']."
"; 

                                $fh = fopen($myfile, 'a+') or die("can't open file");
                                fwrite($fh, $invoice);
                                fclose($fh);
                                  } else {

                                  $invoice = "------------------------------------
"; 
                                $invoice .= "Level 1 Monthly Subscriptionplan Information
"; 
                                $invoice .=  $level1."
"; 
                                $invoice .= "Subscriptionplan:".$row['subscriptionplan']."
"; 
                                $invoice .= "Enrollment Date:".$row['enrollment_date']."
"; 
                                $invoice .= "Monthly Fees:".$row['fees']. "AUD
"; 
                                $invoice .= "Payment Status:".$row['paid']."
"; 
                                $invoice .= "Expiry Date:".$row['expirydate']."
"; 
                                $invoice .= "Payment Due Date:".$row['paidbydate']."
"; 

                                $myfile='invoice/10views'.$_SESSION['u_uid'].'.txt';
                                $fh = fopen($myfile, 'w+') or die("can't open file");
                                fwrite($fh, $invoice);
                                fclose($fh);
                                  }

                      //    header("Location: medical_subscriptionplan.php?medical_subscriptionplan_process_10views=success");
                        } 
            } else {
        if ($views == '100_views') {
        $subscriptionplan = '100_views';
        $views = '100 views';
        $token = 'qqewreqreqwsdfdfdafcbvcQERFGHFGHGFHRETERTDF!@#$%^^()';
          $token = str_shuffle($token);
          $token = substr($token, 0, 10);
          $date = date("Y-m-d: H:i:s");
          $paidbydate = date('Y-m-d H:i:s', strtotime("+2 day"));
          $fees = 50;

        $sql3 = "UPDATE memberships
                        SET subscriptionplan = ?, fees = ?, token = ?, enrollment_date = ?, paidbydate = ?, views = ?
                        WHERE user_uid = ?;

               ";

         $stmt = mysqli_stmt_init($conn);
                        if(!mysqli_stmt_prepare($stmt, $sql3)) {
                           echo "SQL error";
                        } else {
                          mysqli_stmt_bind_param($stmt, "sisssis", $subscriptionplan, $fees, $token, $date, $paidbydate, $views, $_SESSION['u_uid']);
                          mysqli_stmt_execute($stmt);

                          $premium = 1;
                          $sql4 = "UPDATE users
                                   SET premium = ?
                                   WHERE user_uid = ?

                                  ";

                           $stmt = mysqli_stmt_init($conn);
                        if(!mysqli_stmt_prepare($stmt, $sql4)) {
                           echo "SQL error";
                        } else {
                          mysqli_stmt_bind_param($stmt, "is", $premium, $_SESSION['u_uid']);
                          mysqli_stmt_execute($stmt);

                          header("Location: medical_subscriptionplan.php?medical_subscriptionplan_process_100views=success");
        }
        }  

    } else {
        if ($views == 'unlimited') {
                $subscriptionplan = 'unlimited';
        $views = -1;
          $token = 'qqewreqreqwsdfdfdafcbvcQERFGHFGHGFHRETERTDF!@#$%^^()';
          $token = str_shuffle($token);
          $token = substr($token, 0, 10);
          $date = date("Y-m-d H:i:s");
          $paidbydate = date('Y-m-d H:i:s', strtotime("+2 day"));
          $fees = 500;

        $sql5 = "UPDATE memberships
                        SET subscriptionplan = ?, fees = ?, token = ?, enrollment_date = ?, paidbydate = ?, views = ?
                        WHERE user_uid = ?;

               ";

         $stmt = mysqli_stmt_init($conn);
                        if(!mysqli_stmt_prepare($stmt, $sql5)) {
                           echo "SQL error";
                        } else {
                          mysqli_stmt_bind_param($stmt, "sisssis", $subscriptionplan, $fees, $token, $date, $paidbydate, $views, $_SESSION['u_uid']);
                          mysqli_stmt_execute($stmt);

                          $premium = 1;
                          $sql6 = "UPDATE users
                                   SET premium = ?
                                   WHERE user_uid = ?

                                  ";

                           $stmt = mysqli_stmt_init($conn);
                        if(!mysqli_stmt_prepare($stmt, $sql6)) {
                           echo "SQL error";
                        } else {
                          mysqli_stmt_bind_param($stmt, "is", $premium, $_SESSION['u_uid']);
                          mysqli_stmt_execute($stmt);

                           header("Location: medical_subscriptionplan.php?medical_subscriptionplan_process_unlimited_views=success");

}
        }
        }
    }
}
        }
        }
    }
}

/*

 } else {
        if ($views == '100_views') {
        $subscriptionplan = '100_views';
        $views = '100 views';
        $token = 'qqewreqreqwsdfdfdafcbvcQERFGHFGHGFHRETERTDF!@#$%^^()';
          $token = str_shuffle($token);
          $token = substr($token, 0, 10);
          $date = date("Y-m-d: H:i:s");
          $paidbydate = date('Y-m-d H:i:s', strtotime("+2 day"));
          $fees = 50;

        $sql3 = "UPDATE memberships
                        SET subscriptionplan = ?, fees = ?, token = ?, enrollment_date = ?, paidbydate = ?, views = ?
                        WHERE user_uid = ?;

               ";

         $stmt = mysqli_stmt_init($conn);
                        if(!mysqli_stmt_prepare($stmt, $sql3)) {
                           echo "SQL error";
                        } else {
                          mysqli_stmt_bind_param($stmt, "sisssis", $subscriptionplan, $fees, $token, $date, $paidbydate, $views, $_SESSION['u_uid']);
                          mysqli_stmt_execute($stmt);

                          $premium = 1;
                          $sql4 = "UPDATE users
                                   SET premium = ?
                                   WHERE user_uid = ?

                                  ";

                           $stmt = mysqli_stmt_init($conn);
                        if(!mysqli_stmt_prepare($stmt, $sql4)) {
                           echo "SQL error";
                        } else {
                          mysqli_stmt_bind_param($stmt, "is", $premium, $_SESSION['u_uid']);
                          mysqli_stmt_execute($stmt);
            } else {
        if ($views == 'unlimited') {
                $subscriptionplan = 'unlimited';
        $views = -1;
          $token = 'qqewreqreqwsdfdfdafcbvcQERFGHFGHGFHRETERTDF!@#$%^^()';
          $token = str_shuffle($token);
          $token = substr($token, 0, 10);
          $date = date("Y-m-d H:i:s");
          $paidbydate = date('Y-m-d H:i:s', strtotime("+2 day"));
          $fees = 500;

        $sql5 = "UPDATE memberships
                        SET subscriptionplan = ?, fees = ?, token = ?, enrollment_date = ?, paidbydate = ?, views = ?
                        WHERE user_uid = ?;

               ";

         $stmt = mysqli_stmt_init($conn);
                        if(!mysqli_stmt_prepare($stmt, $sql5)) {
                           echo "SQL error";
                        } else {
                          mysqli_stmt_bind_param($stmt, "sisssis", $subscriptionplan, $fees, $token, $date, $paidbydate, $views, $_SESSION['u_uid']);
                          mysqli_stmt_execute($stmt);

                          $premium = 1;
                          $sql6 = "UPDATE users
                                   SET premium = ?
                                   WHERE user_uid = ?

                                  ";

                           $stmt = mysqli_stmt_init($conn);
                        if(!mysqli_stmt_prepare($stmt, $sql6)) {
                           echo "SQL error";
                        } else {
                          mysqli_stmt_bind_param($stmt, "is", $premium, $_SESSION['u_uid']);
                          mysqli_stmt_execute($stmt);


        }
        }
    }
}





      } 
  } 


} 
}

}

}

}
header("Location: index.php?medical_subscriptionplan_process=sucess");
}
}
}
}
}


This is my updated code and everything is working with the database but I am trying to use $row here and got a boolean given error. If I don't use the $row variable, then it is fine....
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向