I am facing difficulty getting data into my database using PDO. The insertion works when I use mysql_connect
/mysql_query
though, so I am sure it's something about PDO I am not getting right:
$db = new PDO("mysql:host=localhost;dbname=XXXXXX","root","");
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
try{
$query= "INSERT INTO tableC VALUES ('1111','2222','XX YY','ERTY','33');";
$result = $conn ->prepare($query);
$result ->execute();
} catch {
echo "PDO error:" . $exception->getMessage();
}
Couple of points: I am using PHP and connecting to WAMP server. PHP version is 5.3.13. I have also checked that my query works.