mysql - PHP/SQL Database querying good practice and security -


So I'm a little experienced PHP developer and since 2007 it is 'the worst thing'; However, whenever it comes to securing my applications, I am relatively n00bish. The way I really know everything I know I can do even more.

I have picked up and reading my way through the way out of the way. I have a few questions for the general SO Group that are related to database queries (mainly under mysql):

When data is inserted into the database, mysql_real_escape_string and normal input (is_numeric etc.) on input data is sufficient? What could be different about different types of attacks from SQL injection.

Can anyone explain stored procedures and prepared statements with a bit more information - you make them and call them. I would like to know how they work, what is going on in the back of the screen?

I work in a php4 bound environment and there is not an option for php5 time. Before there has been any other in this situation, what did you do to protect your applications, while all the cool kids are using that sweet new mysqli interface?

Some common good practices which have proven to be advantageous, the emphasis is on creating an infrastructure capable of upgrading and possible migration (such as running php4 to php5).

Note: A search was made around that which could not find anything similar that killed php-mysql security

  • Use the prepared statement of the PDO parameter
  • You can do something:

      $ pdo_obj = new PDO ('mysql: server = localhost; dbname = mydatabase', $ dbusername, $ dbpassword); $ Sql ​​= 'Select from column' where condition =: condition '; $ Params = array (': condition' => 1); $ Statement = $ pdo_obj- & gt; Prepare ($ sql, aerer (pdo :: atitran = sroo = & gt; PDO :: cursor_food donili)); $ Statement- & gt; Execute ($ params); $ Result = $ statement- & gt; Get All (PDO :: FETCH_ASSOC); 

    PSO:

    1. After avoiding any manual, PDO does all this for you!
    2. It is easy to change this database backend suddenly.

    Brackets:

    • I can not think of anyone.

    Comments

    Popular posts from this blog

    python - Overriding the save method in Django ModelForm -

    html - CSS autoheight, but fit content to height of div -

    qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -