0

我正在尝试将以下信息写入文本文件,并且可以让它在我的 cPanel 中工作,但不能在 VConnect 中工作。你们以前用过VConnect吗?

我已经尝试更改文件夹的名称,并且已经设置了在我的名为 invoice 的文件夹中写入的权限,但仍然无法将其写入文件夹中......其他一切都在工作,但只是创建文件......

    <?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 = "------------------------------------\n"; 
                                $invoice .= "Level 1 Monthly Subscriptionplan Information\n"; 
                                $invoice .=  $level1."\n"; 
                                $invoice .= "Subscriptionplan:".$row['subscriptionplan']."\n"; 
                                $invoice .= "Enrollment Date:".$row['enrollment_date']."\n"; 
                                $invoice .= "Fees:".$row['fees']."\n"; 
                                $invoice .= "Payment Status:".$row['paid']."\n"; 
                                $invoice .= "Expiry Date:".$row['expirydate']."\n"; 
                                $invoice .= "Payment Due Date:".$row['paidbydate']."\n"; 

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

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

                                $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....
4

0 回答 0