Richard Coffre
asked on
Error not raised while executing wrong query
Hi all,
In a previous question (https://www.experts-exchange.com/questions/28646127/Inserting-row-in-Mysql-table-extra-row-and-wrong-character-encoding.html), I created a table with the column "title".
To check what happens when there is an error during the SQL execution I change to "titl" the name of the previous column.
When running the following script, no error is raised and the SQL query really failed.
Why there is no error message?
My script
In a previous question (https://www.experts-exchange.com/questions/28646127/Inserting-row-in-Mysql-table-extra-row-and-wrong-character-encoding.html), I created a table with the column "title".
To check what happens when there is an error during the SQL execution I change to "titl" the name of the previous column.
When running the following script, no error is raised and the SQL query really failed.
Why there is no error message?
My script
<?php
include("data-connection.inc.php");
$sql = "INSERT INTO `pouxdagoalyne`.`TEACHINGS` (`title`, `location`, `teaching_date`, `description`, `opening_hours`) ";
$sql .= "VALUES (:title, :location, :teaching_date, :description, :opening_hours)";
try
{
$sth = $dbh->prepare($sql);
}
catch(PDOException $e)
{
var_dump($e);
}
try
{
$sth->execute(array(':title' => $_POST['teaching-title'], ':location' => $_POST['teaching-location'], ':teaching_date' => $_POST['teaching-when'], ':description' => $_POST['teaching-description'], ':opening_hours' => $_POST['teaching-opening-hours']));
}
catch(PDOException $e)
{
die($e->Message);
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset=utf-8>
<meta name="viewport" content="width=620">
<title>Teaching lesson creation</title>
<link rel="stylesheet" href="">
<script src=""></script>
</head>
<body>
<h1>Create a session: <?php echo $_POST['teaching-title']; ?></h1>
<p>The session <em><?php echo $_POST['teaching-title'] ; ?></em> has been created.</p>
</body>
</html>
ASKER
@AlexanderR, it has changed nothing :-(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
should be
die($e->getMessage());