Jump to content
Larry Ullman's Book Forums

ericp

Members
  • Posts

    58
  • Joined

  • Last visited

Everything posted by ericp

  1. Hi all, Yes, everybody knows that mysqli_free_result() function frees the memory associated with the result. The mysqli_free_result function expects a mysqli_result object as it's parameter. Only mysqli_query calls using SELECT, SHOW, DESCRIBE or EXPLAIN queries will return such an object. Other type of query (including UPDATE) will return a boolean result, which does not need, and should not be, to be freed up using it. So, if you use mysqli_free_result() for your last_login update, you will see the error like this: Warning: mysqli_free_result() expects parameter 1 to be mysqli_result, boolean given in... That's also the reason why Antonio's small script test worked perfectly fine. Eric P
  2. Hi all, The chapter 18, pursue #7 says: 'If you’ve added the last_login field, use it to print a message on the home page as to how many users have logged in in the past, say, hour or day." For my situation, I have finsihed the first 6 number successfully so far. Then, I really do not understand this pursue very clearly. 1/ Does it want us to code how to list/ show the number of users having registered so far? 2/ Does it want us to code to how to show the registered users who are now going live on the website? 3/ Does it ask us to code to how to show the number of users who has logged in at leat once since the date they registered? Can you help me? Thanks Eric
  3. Hi, For me, I use this logic in the query: // Set the last_login date and time: $q = "UPDATE users SET last_login = NOW() WHERE user_id={$_SESSION['user_id']} LIMIT 1"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); // mysqli_free_result($r); mysqli_close($dbc); // Close the database connection. right after the value register comment. Note: I also commented the mysqli_close($dbc); for the SELECT query. Then, I block of code looks like this: . . . if (@mysqli_num_rows($r) == 1) { // A match was made. // Register the values: $_SESSION = mysqli_fetch_array ($r, MYSQLI_ASSOC); mysqli_free_result($r); //mysqli_close($dbc); // Set the last_login date and time: $q = "UPDATE users SET last_login = NOW() WHERE user_id={$_SESSION['user_id']} LIMIT 1"; $r = mysqli_query ($dbc, $q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); mysqli_close($dbc); // Close the database connection. . . . Eric P
  4. Hi Larry, Can you direct me to the correct book so that i can post any other posts just in case? I use this book:
  5. Sorry, larry, but I had posted this before I could search for the another one. Then I went back to delete this post intentionally. However, i don't know how to delete it. I also went to 'My content' in my account, but i couldn't either. Maybe, it's the first time i used your forum. Eric
  6. Thanks for the quick reply. The error is addressed... Eric P/S: 'Four eyes are always better than two eyes, right?'
  7. Hi all, Could you possibly help me with this issue? I coded (first I type every script, then copy-and-pasted due to the error insisted) the script 17.4 - forum.php Then I tested on the web browser. The error happed saying:'Unknown column " p.posted_on' in 'field list' " I captured this error by using the error handler die("Error: ".mysqli_error($dbc)); right after the $r = mysqli_query($dbc, $q); Note: I use the shared host at godaddy.com, PHP version: 5.3.21 OS: Linux domain: http://hiteachers.com/forum.php I look foward to hearing from your help. Regards, Eric
×
×
  • Create New...