0
<?php
    $servername = 'localhost';
    $username = 'root';
    $password = '';
    $dbname = 'testdb1';
    $conn = new PDO('mysql:host='.$servername.';dbname='.$dbname, $username, $password);

How to bind all the variables in this connection command so that I can prevent MySQL injection? Because when I connect to my db like this:

$conn = new PDO('mysql:host=localhost;dbname=testdb1', 'root', '');

Everything is fine and all columns are getting updated properly. But when I use variables in my connection, either I don't get some fields (particularly password column) or I am unable to INSERT to some columns.

please help me!

3

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.