We help IT Professionals succeed at work.
Get Started

Error not raised while executing wrong query

Richard Coffre
Last Modified: 2015-04-16
Hi all,

In a previous question (https://www.experts-exchange.com/Programming/Languages/Scripting/PHP/Q_28646127.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


$sql  = "INSERT INTO `pouxdagoalyne`.`TEACHINGS` (`title`, `location`, `teaching_date`, `description`, `opening_hours`) ";
$sql .= "VALUES (:title, :location, :teaching_date, :description, :opening_hours)";
	$sth = $dbh->prepare($sql);
catch(PDOException $e)

	$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)
<!DOCTYPE html>
<html lang="fr">
<meta charset=utf-8>
<meta name="viewport" content="width=620">
<title>Teaching lesson creation</title>
<link rel="stylesheet" href="">
<script src=""></script>
<h1>Create a session: <?php echo $_POST['teaching-title']; ?></h1>
<p>The session <em><?php echo $_POST['teaching-title'] ; ?></em> has been created.</p>

Open in new window

Watch Question
Enterprise Web Developer
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE