markifornia Posted August 3, 2012 Share Posted August 3, 2012 On line 33 it reads: $words = FALSE; // Flag variable - Why is this needed? Why false boolean? On line 37 it reads: $r = msyqli_query($dbc, $q); if (mysqli_num_rows($r) == 1) { $words = mysqli_fetch_array($r, MYSQLI_ASSOC); } - Is this common practice, to check to see if there is at least one result returned from the query? In some scripts, this is included and then in some it is. For example go to line 47 of the same script, when the array is fetched the function isn't wrapped in the same way as above. Line 46, 47: $r = msyqli_query($dbc, $q); $r = mysqli_fetch_array($r, MYSQLI_ASSOC); Link to comment Share on other sites More sharing options...
Edward Posted August 3, 2012 Share Posted August 3, 2012 Well the database has to check there is at least one record to process the next section. You have to check for something otherwise how can you process next section of script Link to comment Share on other sites More sharing options...
markifornia Posted August 4, 2012 Author Share Posted August 4, 2012 hmm makes sense Edward if (mysqli_num_rows($r) == 1) { it would be a good idea to always wrap the fetch function inside of this conditional block. I have some scripts that don't have this, looks like I'll be looking to modify those now. Link to comment Share on other sites More sharing options...
Recommended Posts