Week 12 - PHP & MySQL Part 3 Flashcards
mysqli_prepare()
- It will first prepare a template of the SQL query and uses ?’s for the values to keys.
- Then the result is stored without executing the code.
- The ?’s will be substituted with the values that the user has entered.
mysqli_bind_param()
Used to bind variables to a prepared statement.
What are SQL injections and how can they be prevented?
SQL injection is a code injection technique that might destroy your database by putting malicious code into form inputs.
A way to reduce these injections is by using mysqli_bind_param() and mysqli_prepare()
What are method for “bulletproofing” errors?
- The error control operator @ is used to suppress any errors which may show up.
It’s used in this way: @mysqli_connect() - Checking submitted form data with isset()
- Using form validation.
die() and exit()
These are statements used for terminating PHP script, meaning that the code will stop running where these statements are called/written.
What’s the difference between mysqli_connect_error() & mysqli_connect_error(connection)?
The first will give the error string from the last database connection attempt, whereas the second show an error string from the last SQL query attempt.
Both will give an empty string if there are no errors.
What’s the difference between mysqli_connect_errorno() & mysqli_connect_errorno(connection)?
The first will give the error number from the last database connection attempt, whereas the second show an error number from the last SQL query attempt.
Both will return a 0 if there are no errors.