Tuesday, 15 April 2014

fwrite - My php quiz is not writing the user's grade to a separate file. I'm not sure if I'm doing this right -


I have a problem writing a user's grade to write my php quiz in a different file. It shows how many people were right / wrong, but it does not write the file What's wrong with my code, which will stop it, or am I missing something? Some creative inputs will be useful.

  & lt ;? Php session_start (); #error_reporting (E_ALL); Ini_set ('display_errors', 1); Need_once ('connect.php'); Need_once "lib.php"; Need_once "utils.php"; $ Quiz_done = true; If (issued ($ _ session ['active'])) {$ email address = $ _SESSION ['emailaddress']; $ Sql ​​= "Select * From user where email address = '$ email address''; if ($ result = mysqli_query ($ link, $ sql)) {while ($ row = mysqli_fetch_array ($ result, MYSQLI_ASSOC)) Quiz from {$ UserID = $ row ['UserID']; $ _SESSION ['UserID'] = $ UserID;}} $ UserID; $ Sql1 = "Select * where userID = '$ userID'"; $ Result1 = mysqli_query ( $ Link, $ sql1); if ($ result1) {while ($ record = mysqli_fetch_row ($ result1)) {if ($ record == $ UserID) {$ quiz_done = true; $ Sql ​​= "Remove from quiz where User ID = '$ userID' "; $ result = mysqli_query ($ link, $ sql);} and {$ quiz_done = false;}}}} {header (" location: login.php ");}? & Gt; Lt; html & gt; & lt; top & Gt; & lt; title & gt; Quiz & lt; / title & gt; & lt; / head & gt; & lt; br & gt; & lt; / br & gt; & lt; br & gt;  body class = "body"> 

There is nothing to write a file here I

  write public functiongrad () {$ content = "" $ Userid Seeing "results"; $ Content = "". $ Your grade ""; $ Content = "\ R \ n"; $ Fp = fopen ($ _ server ['DOCUMENT_ROOT']. "/".$userid.".txt", "wb"); Fwrite ($ fp, $ content); Fclose ($ FP); }  

This is very common, but you should be able to customize your needs in the suite.


No comments:

Post a Comment