php - Fatal error: Call to a member function rowCount() on a non-object in C:\Program Files.... on line 223 -
this question has answer here:
i getting fatal error (location mentioned) in following code
try { $conn = new pdo("mysql:host=$servername1;dbname=userdb", $username1, $password1); $conn->setattribute(pdo::attr_errmode, pdo::errmode_exception); //set pdo error mode exception. //executing query $q=$dbc->exec(" update usertable set username='$username', password='$password' id=1"); echo $q->rowcount()."records updated successfully"; //line 223 error in line echo "step 4 successfull"; } catch(pdoexception $e) { echo $q. $e->getmessage() . "<br>"; die(); } $dbc = $q = null;
you should this:
$dbc->rowcount()
if query getting executed propely
$q=$dbc->exec(" update usertable set username='$username', password='$password' id=1");
else use
$conn
both $conn ->exec()
, $conn ->rowcount()
Comments
Post a Comment