Week 12 - PHP & MySQL Part 3 Flashcards

1
Q

mysqli_prepare()

A
  1. It will first prepare a template of the SQL query and uses ?’s for the values to keys.
  2. Then the result is stored without executing the code.
  3. The ?’s will be substituted with the values that the user has entered.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

mysqli_bind_param()

A

Used to bind variables to a prepared statement.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are SQL injections and how can they be prevented?

A

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()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are method for “bulletproofing” errors?

A
  • 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

die() and exit()

A

These are statements used for terminating PHP script, meaning that the code will stop running where these statements are called/written.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What’s the difference between mysqli_connect_error() & mysqli_connect_error(connection)?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What’s the difference between mysqli_connect_errorno() & mysqli_connect_errorno(connection)?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly