Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/24/2021 in all areas

  1. an ->execute() call can fail due to something wrong with the data being supplied to the query. what's your error handling for that case? i also see you edited a post above to add the code for the addComment method. you are using a prepared query. do NOT also use mysqli_real_escape_string on the data. this will result in the actual escape characters \ being inserted into the database, which will prevent searches from matching data. the main point of using a prepared query is to protect against sql special characters from breaking the sql query syntax, for all data types, not just strings. i also see you are applying nl2br to the input data. this is an OUTPUT function. it is used when you output data in a html context. do NOT use it on input data being stored in a database.
    1 point
  2. Time to re-evaluate then. Your function doesn't return anything. In that case, trying to capture a return value results in NULL which when used in an if statement equates to false. If you want to return a value from a function, you need to do so explicitly with the return keyword. So you need to either modify your function to return true or false appropriately or just remove your if statement where you call the function.
    1 point
  3. There are some fundamentals that you need to understand. Take a look at variable scope and how to pass variables from one function/method to another, visibility and how it affects properties and methods, and static methods and properties. Once you work on that you can look at the pattern you're using - right now you're going from the outside in. You're calling to the display functions and asking them to include the functions that do the work. You want to call the functions that do the work, store the result of that work, then pass that to the display class.
    1 point
This leaderboard is set to New York/GMT-05:00
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.