<?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!