JimTrail Posted October 3, 2016 Share Posted October 3, 2016 Hello W3SchoolsForums; Question 1: Does the PDO module have to be installed on the server for the below query to work? Question 2: Is the $dbh variable used only to assign to the $stmt variable or does it have an additional use? $stmt = $dbh->prepare("INSERT INTO Customers (CustomerName,Address,City) VALUES (:nam, :add, :cit)"); $stmt->bindParam(':nam', $txtNam); $stmt->bindParam(':add', $txtAdd); $stmt->bindParam(':cit', $txtCit); $stmt->execute(); Source: http://www.w3schools.com/sql/sql_injection.asp Thanks. Link to comment Share on other sites More sharing options...
justsomeguy Posted October 3, 2016 Share Posted October 3, 2016 On older versions of PHP you have to enable the PDO extension to use PDO at all. Whether or not the server supports PDO doesn't affect individual queries though. The page you linked to doesn't show it, but the $dbh variable would presumably be the PDO object itself. There are some examples here of creating a new PDO object: http://php.net/manual/en/pdo.construct.php Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now