I wanted to change from normal mysql query to PDO but since that time I can’t even track the fault back.
Is there anyone out there to help me? Any hint would be appreciated!
Q1: what is wrong? Q2: how can the fault be tracked generally?
<?php
// Check if add button active, start this
if (isset($_POST['create'])) {
$new=htmlspecialchars($_POST['newgroup']);
$sql = "INSERT INTO contactgroups (status, gr_name) VALUES(1, : new )";
$sql->bindvalue( ': new', $new);
$sql->execute();
$arr = $sql->errorInfo();
echo $arr;
echo "<meta http-equiv=\"refresh\" content=\"0;URL=groups.php\">";
}
?>
<form id="group-in" method="post" action="groups.php">
Add new Distribution group: <input type="text" name="newgroup" placeholder="name..."> <input type="submit" name="create" value="Create new">
Rename groupname: <input type="text" value="<?php echo $result['gr_name']; ?>"> <input type="submit" name="rename" value="Rename">
</form>
the $_POST is coming, the SQL is running but after the bindPARAM/bindVALUE nothing comes…
You never prepare your sql statement above.
In order to run, you would first need to initialize the DB and create a new PDO instance. Assuming you have this done before:
You can wrap a function/code bit with a try/catch statement and enable exception handling with PDO to get better insight into errors going forward.