Hello Stack Overflow! Im trying to connect to a database and update a certain set of records dependent on the information sent to the web server. When I execute the PHP page and get a result of no errors, nothing updates on the database. As if the query did not even execute. Also I can manually execute it, it works fine like you would expect. The PDO driver connection is setup correctly and does not declare an error.
My Code:
(The Connection Information is declared in a separate database.php file, as well as the table names. This is only the part of the code that interacts on the part that malfunctions.)
<? php
include "database.php";
$conn = new MySQLi($host, $username, $password, $db_name);
if ($conn - > connect_error) {
die("Connection failed: ".$conn - > connect_error);
}
$conp = new PDO("mysql:host=$host;port=3306;dbname=$db_name", $username, $password);
$conp - > setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conp - > setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
try {
$sql = null;
$sql1 = $conp - > prepare("UPDATE `".$tbl_bans_name.
"` SET `resolved`='1' WHERE `Date`=':date' AND `Reason`=':reason'");
$sql1 - > bindParam(':date', $date);
$sql1 - > bindParam(':reason', $reason);
if ($sql1 - > execute()) {
echo "good";
}
$sql1 = null;
} catch (PDOException $e) {
print_r($e);
}
//$execute = Mysqli_query($conn, $sql1);
//mysqli_close($conn);
?>
Any and all help is appreciated! I would be grateful because this problem has been troubling me for the past few hours.
</div>