How to test whether PDO calling method is successful
邯郸易住宋至刚
邯郸易住宋至刚 2019-08-03 19:08:25
0
2
1586

When using PDO, the database connection is normal, but when running this code, the page displays neither results nor errors. Is it because PDO on my side cannot call its method?

<?php
/**
PDO connection database
*/

include 'pdo_conf.php';

$dsn = "{$dbType}:host ={$host};dbName={$userName}";
try{
$pdo = new PDO($dsn,$userName,$password);
// echo '<h3>Connect Success</h3>';
$sql = "UPDATE `student` SET `name` = 'Qin Mingyi' WHERE `student`.`id` = 14;)";
$num = $ pdo->exec($sql);
$insertId = $pdo->lastInsertId();
if($num > 0){
print 'Successfully added'.$num. 'Record, the latest added record ID is'.$insertId;
}
}catch (PDOException $e){
die('Operation failed'.$e->getMessage());
}include 'pdo_conf.php';

$dsn = "{$dbType}:host={$host};dbName={$userName}";
try{
$pdo = new PDO($dsn,$userName,$password);
// echo '<h3>Connection successful</h3>';
$sql = "UPDATE `student` SET `name` = 'Qin Mingyi' WHERE `student`.`id` = 14;)";
$num = $pdo->exec($sql);
$insertId = $pdo->lastInsertId() ;
if($num > 0){
print ''.$num.' records were added successfully, the latest added record ID is '.$insertId;
}
}catch ( PDOException $e){
die('Operation failed'.$e->getMessage());
}

邯郸易住宋至刚
邯郸易住宋至刚

//m.sbmmt.com/course/1073.html

reply all(2)
邯郸易住宋至刚

But the problem is that the data was not added successfully.

在路上...

If there is no indication, the connection is successful

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template