Is this correct way to prevent SQL injection?

Coo00000ode BREAKKKKERRRR

Question to hacker profesionals.

I checked a lot of similar questions and PHP Manual doc along with W3SCHOOLS and they all use different methods that im going crazy with all the possible methods (not sure which one to use?)

(for example PHP Manual uses bind param function:

$stmt->bind_param('sssd', $code, $language, $official, $percent);

But i couldnt get it working so I used this one:

$queryString = "SELECT * FROM mytable WHERE dom='%s' AND key='%s' AND user_id='%i";
$stmt = $wpdb->get_results( $wpdb->prepare($queryString, $dom, $key, $user_id) );

(I assumed %i is integer and %s is string) - this code works but not sure if it prevents sql injection.

Is this correct and enough to prevent SQL injection? (ps variables are normaly created before this, like $dom = "mydom";)

Thanks a lot!

D. Simmons

In your example, I see that you are using Wordpress functions so going that route you should consult the documentation for what you are doing, specifically prepare() https://developer.wordpress.org/reference/classes/wpdb/prepare/

Which states "Prepares a SQL query for safe execution..."

So essentially yes you are protecting your query albeit by trusting that Wordpress is doing it correctly internally.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How can I prevent SQL injection in PHP?

From Java

Are PDO prepared statements sufficient to prevent SQL injection?

From Dev

Prevent Sql injection in nhibernate

From Dev

How to prevent SQL Injection in Wordpress?

From Dev

How to prevent SQL injection in Laravel?

From Dev

SQL Injection: Which statement can prevent better SQL injection

From Dev

Prevent SQL injection without using cfqueryparam

From Dev

Can this prepared statement prevent SQL injection?

From Dev

Prevent Sql Injection (Java)

From Dev

Is this correct way dependency injection in Angular?

From Dev

prevent sql injection in mysqli

From Dev

How to prevent sql-injection in nodejs and sequelize?

From Dev

Is blocking query commands enough to prevent SQL injection?

From Dev

How does Binding parameters prevent Sql Injection?

From Dev

Prevent SQL injection with PostgreSQL COPY JDBC

From Dev

How to prevent sql injection in php mysql?

From Dev

Confirmation of correct use of code to prevent SQL injection and correct use of the using statement

From Dev

Prevent sql injection on datetime string input

From Dev

Prevent from sql injection in this php code

From Dev

Will this code prevent SQL injection (Python)

From Dev

prevent sql injection attack in dynamic query grails

From Dev

Prevent SQL injection in oracle

From Dev

Prevent sql injection, Activerecord #where, with multiple AND/OR clause

From Dev

Prevent SQL Injection In This PHP Code

From Dev

Is this a good way for SQL injection prevention

From Dev

Am I safe?? [trying to prevent sql injection]

From Dev

prevent sql injection in laravel

From Dev

Best way to prevent sql "injection" when using column as variable

From Dev

Prevent sql injection in dynamic code

Related Related

  1. 1

    How can I prevent SQL injection in PHP?

  2. 2

    Are PDO prepared statements sufficient to prevent SQL injection?

  3. 3

    Prevent Sql injection in nhibernate

  4. 4

    How to prevent SQL Injection in Wordpress?

  5. 5

    How to prevent SQL injection in Laravel?

  6. 6

    SQL Injection: Which statement can prevent better SQL injection

  7. 7

    Prevent SQL injection without using cfqueryparam

  8. 8

    Can this prepared statement prevent SQL injection?

  9. 9

    Prevent Sql Injection (Java)

  10. 10

    Is this correct way dependency injection in Angular?

  11. 11

    prevent sql injection in mysqli

  12. 12

    How to prevent sql-injection in nodejs and sequelize?

  13. 13

    Is blocking query commands enough to prevent SQL injection?

  14. 14

    How does Binding parameters prevent Sql Injection?

  15. 15

    Prevent SQL injection with PostgreSQL COPY JDBC

  16. 16

    How to prevent sql injection in php mysql?

  17. 17

    Confirmation of correct use of code to prevent SQL injection and correct use of the using statement

  18. 18

    Prevent sql injection on datetime string input

  19. 19

    Prevent from sql injection in this php code

  20. 20

    Will this code prevent SQL injection (Python)

  21. 21

    prevent sql injection attack in dynamic query grails

  22. 22

    Prevent SQL injection in oracle

  23. 23

    Prevent sql injection, Activerecord #where, with multiple AND/OR clause

  24. 24

    Prevent SQL Injection In This PHP Code

  25. 25

    Is this a good way for SQL injection prevention

  26. 26

    Am I safe?? [trying to prevent sql injection]

  27. 27

    prevent sql injection in laravel

  28. 28

    Best way to prevent sql "injection" when using column as variable

  29. 29

    Prevent sql injection in dynamic code

HotTag

Archive