Using PDO connection to MySQL. I can't retrieve the number of affected rows for an "INSERT INTO" query
$sql = 'insert into ... '; $q = $dbh->prepare($sql); $q = $q->execute(); echo ( $q->rowCount() ); echo ( $q->affectedRows() ); Fatal error: Call to a member function rowCount() on a non-object.
Fatal error: Call to a member function affectedRows() on a non-object.
The record is inserted successfully but I can't check it because it won't return anything. What is wrong?