Error message not being shown

Dear All,
At the top of my php page I put this ERROR_REPORTING(E_ALL); but even than the error message does not appear and the pages goes blank. Anything else I must do for the error message to appear? Thank you.

Good call! That’ll make tracking down the ini file a lot easier.

Dear Immerse,
Where is this php.ini file is normally located? Can I create one is it? What must I write in the file? Thank you.

Dear Space,
Ok I found it. It is at /etc/php.ini. So what is my next step? Thank you.

No, as that will generate an error before the script is even executed (i.e. before the ini_set() call).

If you want to make sure all errors are displayed, you’ll need to change your php.ini file.

Dear Antohy,
In case there is any missing curly brackets can it be notified via the error message? Thank you.

Run this:

<?php

phpinfo()

?>

In the output from that very near the top, one entry will be “Loaded Configuration File” the value for that is the location of the php.ini file which PHP is using.

What OS are you using?
Are you testing on your own computer or have you already uploaded it to your host?
Please let us know, then we can tell you where your php.ini is stored :slight_smile:

While you are at it, search the HDD for php.ini, you may find you have more than one php.ini file, which can happen if you try more than one install which can then become a nightmare to debug.

Ok, give this a little whirl.


<?php
error_reporting(-1);
ini_set('display_errors', true);

include 'script-with-errors.php';

?>

Have you checked your error log?

Can the script you’re using be posted here?

Dear Antohy,
Attached is my script but I have managed to settle my bug but I need this for future use. Can you tell me what exactly to be done? What is this “include ‘script-with-errors.php’;” Must I create on is it? Thank you.

<?php
error_reporting(-1);
ini_set(‘display_errors’, true);
$searchUser=$_GET[‘searchUser’];
$searchcm=$_GET[‘searchcm’];
?>
<head>
<script>
function submitForm() {
document.forms[0].submit()
return false
}

function checkEnter(e)
{ //e is event object passed from function invocation
var characterCode;
// literal character code will be stored in this variable

if(e && e.which)
{ //if which property of event object is supported (NN4)
e = e
characterCode = e.which //character code is contained in NN4's which property
}
else
{
e = event
characterCode = e.keyCode //character code is contained in IE's keyCode property
}

if(characterCode == 13)
{ //if generated character code is equal to ascii 13 (if enter key)
document.forms[0].submit() //submit the form
return false 
}
else
{
return true 
}

}
</script>
</head>

<html>
<link rel=“stylesheet” type=“text/css” href=“view.css” media=“all”>

<body>
<img src=“images/header-bg.jpg”>
<form>

<table align=“center” id=“vehicle”>
<tr align=“left”>
<td>
<input type=button name=“Add Driver” value=“Add Driver” onClick=“window.location=‘addDriver.php’”>
</td>
</tr>
<tr bgcolor=“#83A7D1”>
<td width=“6%” bordercolor=“#999999”><div align=“center” class=“style15”><span class=“style5 style15”>No.</span></div></td>
<td width=“18%” bordercolor=“#999999”><div align=“center” class=“style5 style15”>
<div align=“center”>Name</div>
</div>
</td>
<td width=“18%” bordercolor=“#999999”><div align=“center” class=“style5 style15”>
<div align=“center”>I/D No</div>
</div>
</td>
<td width=“18%” bordercolor=“#999999”><div align=“center” class=“style5 style15”>
<div align=“center”>Employee Name</div>
</div>
</td>
<td width=“11%” bordercolor=“#999999”><div align=“center” class=“style5 style15”>
<div align=“center”>Parameters</div>
</div>
</td>
</tr>

<?php
require_once(‘config.php’);
//Connect to mysql server
$link = mysql_connect(dbHost, dbUser, dbPassword);
if(!$link) {
die('Failed to connect to server: ’ . mysql_error());
}

//Select database
$db = mysql_select_db(dbDatabase);
if(!$db) {
	die("Unable to select database");
}

$searchsql =“”;

if ($searchcm <> “”)
{
$searchsql = $searchsql."AND tblDriver.driverName LIKE ‘%$searchcm%’ ";
$searchpage=0;
}

if ($selectpage == 0)
$selectpage = 1;

$query = "Select tblDriver.driverName,tblDriver.driverIDNo, tblDriver.driverCurrentEmployerID FROM tblDriver ".$searchsql;
//echo $query;
$result = mysql_query($query);
$num_rows = mysql_num_rows($result);
$num_pages = (($num_rows-($num_rows % 15))/15) + 1;
//echo "num of row : ".$num_rows;
$query = “SELECT tblDriver.driverID,tblDriver.driverName,tblDriver.driverIDNo, tblFleet.fleetName From tblDriver,tblFleet Where tblDriver.driverCurrentEmployerID=tblFleet.fleetID “.$searchsql.” ORDER BY tblDriver.driverName ASC LIMIT “.(($selectpage-1)*15).”, 15”;
//echo $query;
$result = mysql_query($query);
$count =(($selectpage-1)*15);

$count=0;
//driverDetails.php?driverID={$row[‘driverID’]}
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$count++;

echo "&lt;tr&gt;
&lt;td bordercolor=\\"#999999\\" bgcolor=\\"#FFFFFF\\"&gt;&lt;div align=\\"center\\"&gt;&lt;span class=\\"style12\\"&gt;$count.&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;
&lt;td bordercolor=\\"#999999\\" bgcolor=\\"#FFFFFF\\"&gt;&lt;span class=\\"style10\\"&gt;&lt;span class=\\"style12\\"&gt;{$row['driverName']} &lt;/span&gt;&lt;/span&gt;&lt;/td&gt;
	&lt;td bordercolor=\\"#999999\\" bgcolor=\\"#FFFFFF\\"&gt;&lt;span class=\\"style10\\"&gt;&lt;span class=\\"style12\\"&gt;{$row['driverIDNo']} &lt;/span&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td bordercolor=\\"#999999\\" bgcolor=\\"#FFFFFF\\"&gt;&lt;span class=\\"style10\\"&gt;&lt;span class=\\"style12\\"&gt;{$row['fleetName']} &lt;/span&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td valign=\\"middle\\" bordercolor=\\"#999999\\" bgcolor=\\"#FFFFFF\\"&gt;&lt;div align=\\"center\\"&gt;&lt;a href=\\"editDriver.php?driverID={$row['driverID']}\\"&gt;Details&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;";

}
mysql_close();
?>
<? if ($cancel==“”)
{
?>
<tr>
<td colspan=“4” bordercolor=“#999999” bgcolor=“#83A7D1”>
<form id=“form1” name=“form1” method=“post” action=“”>
<label>
<span class=“style17”>Search</span>
<input type=“text” name=“searchcm” id=“searchcm” onKeyPress=“checkEnter(event)” value=<?=$searchcm?>>
</label> <? if ($searchcm<>“”) { ?>
<a href=“gridDriverSupervisor.php?searchcm=”><span class=“style17”>Clear Search</span></a>
<? } ?>

            &lt;/td&gt;
            &lt;td width="11%" bordercolor="#999999" bgcolor="#83A7D1" class="style17"&gt;&lt;div align="center"&gt;
              &lt;select onchange="this.form.submit();" name="selectpage" id="selectpage"&gt;
							   &lt;? $i = 0; 
							     for ($i=1;$i&lt;=$num_pages;$i++)
							   { ?&gt;
			                    &lt;option &lt;? if ($i == $selectpage) { ?&gt; selected="selected" &lt;? } ?&gt; value="&lt;?=$i?&gt;"&gt;&lt;?=$i?&gt;&lt;/option&gt;
								&lt;? } ?&gt;
              &lt;/select&gt;
              &lt;/div&gt;
            &lt;/td&gt;
          &lt;/tr&gt;             
        &lt;/table&gt;
        &lt;p&gt;&nbsp;&lt;/p&gt;&lt;/td&gt;

</tr>
<?
}
?>

</table>

<table align=“center” id=“user”>
<tr align=“left”>
<td>
<input type=button name=“Add User” value=“Add User” onClick=“window.location=‘addUser.php’”>
</td>
</tr>
<tr bgcolor=“#83A7D1”>
<td width=“6%” bordercolor=“#999999”><div align=“center” class=“style15”><span class=“style5 style15”>No.</span></div></td>
<td width=“18%” bordercolor=“#999999”><div align=“center” class=“style5 style15”>
<div align=“center”>User Name</div>
</div>
</td>
<td width=“18%” bordercolor=“#999999”><div align=“center” class=“style5 style15”>
<div align=“center”>User Full Name</div>
</div>
</td>
<td width=“18%” bordercolor=“#999999”><div align=“center” class=“style5 style15”>
<div align=“center”>User Contact Number</div>
</div>
</td>
<td width=“11%” bordercolor=“#999999”><div align=“center” class=“style5 style15”>
<div align=“center”>Parameters</div>
</div>
</td>
</tr>

<?php
require_once(‘config.php’);
//Connect to mysql server
$link = mysql_connect(dbHost, dbUser, dbPassword);
if(!$link) {
die('Failed to connect to server: ’ . mysql_error());
}

//Select database
$db = mysql_select_db(dbDatabase);
if(!$db) {
	die("Unable to select database");
}

$searchsql =“”;

if ($searchUser <> “”)
{
$searchsql = $searchsql."Where tblUser.userName LIKE ‘%$searchUser%’ ";
$searchPageUser=0;
}

if ($selectPageUser == 0)
$selectPageUser = 1;

$query2 = "Select tblUser.userName,tblUser.userPassword,tblUser.userPassword From tblUser ".$searchsql;
//echo $query2;
$result2 = mysql_query($query2);
$num_rows2 = mysql_num_rows($result2);
$num_pages2 = (($num_rows2-($num_rows2 % 15))/15) + 1;
//echo "num of row : ".$num_rows2;
//echo "num_pages2 : ".$num_pages2;
$query2 = “Select tblUser.userName,tblUser.userFullName,tblUser.userContactNumber From tblUser “.$searchsql.” Order By tblUser.userName Asc Limit “.(($selectpage-1)*15).”, 15”;
//echo $query2;
$result2 = mysql_query($query2);
$count2 =(($selectPageUser-1)*15);
$count2=0;
//driverDetails.php?driverID={$row[‘driverID’]}
while($row2 = mysql_fetch_array($result2, MYSQL_ASSOC))
{
$count2++;

echo "&lt;tr&gt;
&lt;td bordercolor=\\"#999999\\" bgcolor=\\"#FFFFFF\\"&gt;&lt;div align=\\"center\\"&gt;&lt;span class=\\"style12\\"&gt;$count2.&lt;/span&gt;&lt;/div&gt;&lt;/td&gt;
&lt;td bordercolor=\\"#999999\\" bgcolor=\\"#FFFFFF\\"&gt;&lt;span class=\\"style10\\"&gt;&lt;span class=\\"style12\\"&gt;{$row2['userName']} &lt;/span&gt;&lt;/span&gt;&lt;/td&gt;
	&lt;td bordercolor=\\"#999999\\" bgcolor=\\"#FFFFFF\\"&gt;&lt;span class=\\"style10\\"&gt;&lt;span class=\\"style12\\"&gt;{$row2['userFullName']} &lt;/span&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td bordercolor=\\"#999999\\" bgcolor=\\"#FFFFFF\\"&gt;&lt;span class=\\"style10\\"&gt;&lt;span class=\\"style12\\"&gt;{$row2['userContactNumber']} &lt;/span&gt;&lt;/span&gt;&lt;/td&gt;
&lt;td valign=\\"middle\\" bordercolor=\\"#999999\\" bgcolor=\\"#FFFFFF\\"&gt;&lt;div align=\\"center\\"&gt;&lt;a href=\\"editUser.php?driverID={$row2['userID']}\\"&gt;Details&lt;/a&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;";

}
mysql_close();
?>

<? if ($cancel==“”)
{
?>
<tr>
<td colspan=“4” bordercolor=“#999999” bgcolor=“#83A7D1”>
<form id=“form2” name=“form2” method=“post” action=“”>
<label>
<span class=“style17”>Search</span>
<input type=“text” name=“searchUser” id=“searchUser” onKeyPress=“checkEnter(event)” value=<?=$searchUser?>>
</label> <? if ($searchUser<>“”) { ?>
<a href=“gridDriverSupervisor.php?searchUser=”><span class=“style17”>Clear Search</span></a>
<? } ?>

            &lt;/td&gt;
            &lt;td width="11%" bordercolor="#999999" bgcolor="#83A7D1" class="style17"&gt;&lt;div align="center"&gt;
              &lt;select onchange="this.form.submit();" name="selectPageUser" id="selectPageUser"&gt;
							   &lt;? $j = 0; 
							     for ($j=1;$j&lt;=$num_pages2;$j++)
							   { ?&gt;
			                    &lt;option &lt;? if ($j == $selectPageUser) { ?&gt; selected="selected" &lt;? } ?&gt; value="&lt;?=$j?&gt;"&gt;&lt;?=$j?&gt;&lt;/option&gt;
								&lt;? } ?&gt;
              &lt;/select&gt;
              &lt;/div&gt;
            &lt;/td&gt;
          &lt;/tr&gt;             
        &lt;/table&gt;
        &lt;p&gt;&nbsp;&lt;/p&gt;&lt;/td&gt;

</tr>
<?
}
?>

</table>
</form>
</body>
</html>

Dear Immerse,
I am using centos5.5 so where must I search it then? After searching what is my next step please? Thank you.

In the output from phpinfo() you’ll see “Loaded Configuration File”, that will tell you which php.ini file (assuming you’ve got more then one on the HDD) is in use.

Try this:-


<?php
error_reporting(-1);
ini_set('display_errors', true);

/* Rest of Code */

?>

You could, alternatively, check your error log. :slight_smile:

Dear Anthony,
No luck I have put both the scripts what else must I do for it to appear on the page it self the errors. Really need the errors to help me in my debugging process. Thank you.