Problem Description
**UPDATE 2:**
I have now removed the following from the .php file:
<?php error_reporting( E_ALL ); ?>
I have set display_erros in php.ini as follows:
> display_errors = On
Error reporting is set to the following in `php.ini`:
> error_reporting = E_ALL | E_STRICT
After restarting Apache, I still get no errors/warnings.
**UPDATE 1:**
I have changed error_reporting in `php.ini` from:
> error_reporting = E_ALL &
> ~E_DEPRECATED
to
> error_reporting = E_ALL | E_STRICT
After which I restarted Apache, e.g.
> /etc/init.d/apache2 restart
But the page will still not display errors/warnings of any kind.
**ORIGINAL QUESTION:**
The following script is generating a warning because the $err being inside the if statement. Why is this warning not being displayed on the PHP page in a web browser?
I have to look at the Apache logs to see the warning. Also, if I deliberately change the "insert into" to "delete into", it does not display an error on the PHP page. Why are the errors not displaying on the actual PHP page?
<?php
error_reporting(E_ALL);
?>
<html>
<head>
<title></title>
<link rel="icon" type="image/png" href="favicon.ico">
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$err = array();
if (empty( $_POST['display_name']))
$err[] = "display name field is required";
if (empty( $_POST['email']))
$err[] = "email field is required";
if (empty( $_POST['password']))
$err[] = "password field is required";
if (!$err) {
try {
$DBH = new PDO("mysql:host=localhost;dbname=database1", "user", "pass");
$DBH->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$STH = $DBH->prepare("delete into table1 (display_name, email, password) values ( :display_name, :email, :password )");
$STH->bindParam(':display_name', $_POST['display_name'], PDO::PARAM_STR, 100);
$STH->bindParam(':email', $_POST['email'], PDO::PARAM_STR, 100);
$STH->bindParam(':password', $_POST['password'], PDO::PARAM_STR, 100);
$STH->execute();
$STH = $DBH->prepare("delete into table2 ( username, status, users_id ) values ( :username, :status, :users_id )");
$strStatus = 1;...
AI-Generated Solution
Powered by LMSouq AI · GPT-4.1-mini
Analyzing problem and generating solution…
Was this solution helpful?