Will not report errors what can I do

This is a discussion on Will not report errors what can I do within the PHP General Discussion (php.general) forum.

Will not report errors what can I do

Postby Terion Miller on Thu Dec 04, 2008 3:20 pm

Hey everyone I am still fighting the same problem that my script isn't
working and its not reporting errors, when you click to "view" the work
order it doesn't do anything, I have all kinds of error reporting turned on
but nothing, do I have them syntax wrong?

<?php
include("inc/dbconn_open.php");
error_reporting(E_ALL);
ini_set('display_errors', '1');
error_log("errors.txt");


if (empty($_SESSION['AdminLogin']) OR $_SESSION['AdminLogin'] <> 'OK' ){
header ("Location: LogOut.php");
}

if (isset($_GET['AdminID']) && !empty($_GET['AdminID'])){
$AdminID = $_GET['AdminID'];
} else {
header ("Location: LogOut.php");
}

$query = "SELECT ViewAllWorkOrders FROM admin WHERE AdminID='$AdminID'";
$result = mysql_query ($query);
$row = mysql_fetch_object ($result);
if ($row->ViewProjects == "NO") {
header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry, you do
not have access to that page.");
}

if (isset($_GET['WorkOrderID'])) {$WorkOrderID = $_GET['WorkOrderID'];} else
{$WorkOrderID = '';}
if (isset($_GET['ReturnPage'])) {$ReturnPage = $_GET['ReturnPage'];} else
{$ReturnPage = 'Welcome.php';}


$sql = "SELECT FormName FROM workorders WHERE
WorkOrderID='$WorkOrderID'";
$result = mysql_query ($sql);
$row = mysql_fetch_object ($result);


if (mysql_num_rows($result) > 0) {

if ($row->FormName == "WorkOrder") {
header ("Location:
ViewWorkOrder.php?AdminID=$AdminID&WorkOrderID=$WorkOrderID&ReturnPage=$ReturnPage");
}elseif ($row->FormName == "PD_Coupon") {
header ("Location:
ViewPD_Coupon.php?AdminID=$AdminID&WorkOrderID=$WorkOrderID&ReturnPage=$ReturnPage");
}elseif ($row->FormName == "PD_TextAd") {
header ("Location:
ViewPD_TextAd.php?AdminID=$AdminID&WorkOrderID=$WorkOrderID&ReturnPage=$ReturnPage");
}elseif ($row->FormName == "PD_Enhanced") {
header ("Location:
ViewPD_Enhanced.php?AdminID=$AdminID&WorkOrderID=$WorkOrderID&ReturnPage=$ReturnPage");
}elseif ($row->FormName == "HS_Builder") {
header ("Location:
ViewHomescape_Builder.php?AdminID=$AdminID&WorkOrderID=$WorkOrderID&ReturnPage=$ReturnPage");
}elseif ($row->FormName == "HS_SpecHome") {
header ("Location:
ViewHomescape_SpecHome.php?AdminID=$AdminID&WorkOrderID=$WorkOrderID&ReturnPage=$ReturnPage");
} else {
header ("Location: Welcome.php?AdminID=$AdminID&msg=Nothing
works Does it....");
}
} else {
header ("Location: Welcome.php?AdminID=$AdminID&msg=Nothing
Works..grrrr");
}
?>
Terion Miller
 
Posts: 15
Joined: Tue Nov 18, 2008 7:50 am

Re: [PHP] Will not report errors what can I do

Postby Ashley Sheridan on Thu Dec 04, 2008 3:37 pm

On Thu, 2008-12-04 at 16:20 -0600, Terion Miller wrote:
> Hey everyone I am still fighting the same problem that my script isn't
> working and its not reporting errors, when you click to "view" the work
> order it doesn't do anything, I have all kinds of error reporting turned on
> but nothing, do I have them syntax wrong?
>
> > include("inc/dbconn_open.php");
> error_reporting(E_ALL);
> ini_set('display_errors', '1');
> error_log("errors.txt");
>
>
> if (empty($_SESSION['AdminLogin']) OR $_SESSION['AdminLogin'] <> 'OK' ){
> header ("Location: LogOut.php");
> }
>
> if (isset($_GET['AdminID']) && !empty($_GET['AdminID'])){
> $AdminID = $_GET['AdminID'];
> } else {
> header ("Location: LogOut.php");
> }
>
> $query = "SELECT ViewAllWorkOrders FROM admin WHERE AdminID='$AdminID'";
> $result = mysql_query ($query);
> $row = mysql_fetch_object ($result);
> if ($row->ViewProjects == "NO") {
> header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry, you do
> not have access to that page.");
> }
>
> if (isset($_GET['WorkOrderID'])) {$WorkOrderID = $_GET['WorkOrderID'];} else
> {$WorkOrderID = '';}
> if (isset($_GET['ReturnPage'])) {$ReturnPage = $_GET['ReturnPage'];} else
> {$ReturnPage = 'Welcome.php';}
>
>
> $sql = "SELECT FormName FROM workorders WHERE
> WorkOrderID='$WorkOrderID'";
> $result = mysql_query ($sql);
> $row = mysql_fetch_object ($result);
>
>
> if (mysql_num_rows($result) > 0) {
>
> if ($row->FormName == "WorkOrder") {
> header ("Location:
> ViewWorkOrder.php?AdminID=$AdminID&WorkOrderID=$WorkOrderID&ReturnPage=$ReturnPage");
> }elseif ($row->FormName == "PD_Coupon") {
> header ("Location:
> ViewPD_Coupon.php?AdminID=$AdminID&WorkOrderID=$WorkOrderID&ReturnPage=$ReturnPage");
> }elseif ($row->FormName == "PD_TextAd") {
> header ("Location:
> ViewPD_TextAd.php?AdminID=$AdminID&WorkOrderID=$WorkOrderID&ReturnPage=$ReturnPage");
> }elseif ($row->FormName == "PD_Enhanced") {
> header ("Location:
> ViewPD_Enhanced.php?AdminID=$AdminID&WorkOrderID=$WorkOrderID&ReturnPage=$ReturnPage");
> }elseif ($row->FormName == "HS_Builder") {
> header ("Location:
> ViewHomescape_Builder.php?AdminID=$AdminID&WorkOrderID=$WorkOrderID&ReturnPage=$ReturnPage");
> }elseif ($row->FormName == "HS_SpecHome") {
> header ("Location:
> ViewHomescape_SpecHome.php?AdminID=$AdminID&WorkOrderID=$WorkOrderID&ReturnPage=$ReturnPage");
> } else {
> header ("Location: Welcome.php?AdminID=$AdminID&msg=Nothing
> works Does it....");
> }
> } else {
> header ("Location: Welcome.php?AdminID=$AdminID&msg=Nothing
> Works..grrrr");
> }
> ?>
Couple of things to check here:

* is the web server working correctly?
* do you have permission to set the reporting level (strange but not
impossible)
* are you sure it's not a logic error in your code rather than a syntax
error

I notice you're using a LOT of header("Location: ..."); calls, which I'd
advise against, but if you must use them, there are sometimes problems
when you don't specify the full URL of the page you need to locate to.


Ash
www.ashleysheridan.co.uk

Ashley Sheridan
 
Posts: 100
Joined: Sun Aug 17, 2008 6:15 am

Re: [PHP] Will not report errors what can I do

Postby Jim Lucas on Thu Dec 04, 2008 4:07 pm

Terion Miller wrote:
> Hey everyone I am still fighting the same problem that my script isn't
> working and its not reporting errors, when you click to "view" the work
> order it doesn't do anything, I have all kinds of error reporting turned on
> but nothing, do I have them syntax wrong?
>
> > include("inc/dbconn_open.php");
> error_reporting(E_ALL);
> ini_set('display_errors', '1');

This is boolean, it should be ini_set('display_errors', 1);

> error_log("errors.txt");
>
>
> if (empty($_SESSION['AdminLogin']) OR $_SESSION['AdminLogin'] <> 'OK' ){
> header ("Location: LogOut.php");
> }
>
> if (isset($_GET['AdminID']) && !empty($_GET['AdminID'])){
> $AdminID = $_GET['AdminID'];
> } else {
> header ("Location: LogOut.php");
> }
>
> $query = "SELECT ViewAllWorkOrders FROM admin WHERE AdminID='$AdminID'";
> $result = mysql_query ($query);

Not the best solution, but add this to the above line...

$result = mysql_query ($query) or die(mysql_error());


> $row = mysql_fetch_object ($result);

This isn't going to work. Above in your select statement, you are only selecting the ViewAllWorkOrders column.

But then here, you are trying to access a column/object called ViewProjects. Where do you think this column/object is coming from?
It needs to exist in your previous select statement for it to work correctly, otherwise, what point is your first select statement?
> if ($row->ViewProjects == "NO") {
> header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry, you do
> not have access to that page.");
> }
>
> if (isset($_GET['WorkOrderID'])) {$WorkOrderID = $_GET['WorkOrderID'];} else
> {$WorkOrderID = '';}
> if (isset($_GET['ReturnPage'])) {$ReturnPage = $_GET['ReturnPage'];} else
> {$ReturnPage = 'Welcome.php';}
>
>
> $sql = "SELECT FormName FROM workorders WHERE
> WorkOrderID='$WorkOrderID'";
> $result = mysql_query ($sql);

same thing for the error reporting here

$result = mysql_query ($sql) or die(mysql_error());


The following line will through an error is you have no results
> $row = mysql_fetch_object ($result);
>

put the previous mysql_fetch_object() call after the following if statement.

>
> if (mysql_num_rows($result) > 0) {
>

like this
$row = mysql_fetch_object ($result);


> if ($row->FormName == "WorkOrder") {
> header ("Location:
> ViewWorkOrder.php?AdminID=$AdminID&WorkOrderID=$WorkOrderID&ReturnPage=$ReturnPage");
> }elseif ($row->FormName == "PD_Coupon") {
> header ("Location:
> ViewPD_Coupon.php?AdminID=$AdminID&WorkOrderID=$WorkOrderID&ReturnPage=$ReturnPage");
> }elseif ($row->FormName == "PD_TextAd") {
> header ("Location:
> ViewPD_TextAd.php?AdminID=$AdminID&WorkOrderID=$WorkOrderID&ReturnPage=$ReturnPage");
> }elseif ($row->FormName == "PD_Enhanced") {
> header ("Location:
> ViewPD_Enhanced.php?AdminID=$AdminID&WorkOrderID=$WorkOrderID&ReturnPage=$ReturnPage");
> }elseif ($row->FormName == "HS_Builder") {
> header ("Location:
> ViewHomescape_Builder.php?AdminID=$AdminID&WorkOrderID=$WorkOrderID&ReturnPage=$ReturnPage");
> }elseif ($row->FormName == "HS_SpecHome") {
> header ("Location:
> ViewHomescape_SpecHome.php?AdminID=$AdminID&WorkOrderID=$WorkOrderID&ReturnPage=$ReturnPage");
> } else {
> header ("Location: Welcome.php?AdminID=$AdminID&msg=Nothing
> works Does it....");
> }
> } else {
> header ("Location: Welcome.php?AdminID=$AdminID&msg=Nothing
> Works..grrrr");

Put curly brackets around all variables in the preceding header() calls

> }
> ?>
>

and for the love of , run mysql_real_escape_string() on your input before using it in a statement...

Also, if you have a parse error within the page, or included pages, none of the error reporting you have set will make any difference.

for you to ensure that error reporting in enabled, you need to have it set in the php.ini, the virtualhost block, or .htaccess files if they are an
option.

Hope this helps

--
Jim Lucas

"Some men are born to greatness, some achieve greatness,
and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare
Jim Lucas
 
Posts: 625
Joined: Fri Jul 11, 2003 4:19 pm

Re: [PHP] Will not report errors what can I do

Postby Johny John on Thu Dec 04, 2008 10:16 pm

HI Terion,
Please put the error reporting on top of the page and try. If you have any
errors in the include file, it won't execute the rest of commands. Make the
changes to code as follows.

error_reporting(E_ALL);
ini_set('display_errors', '1');
include("inc/dbconn_open.php");

?>

Regards,

Johny John

www.phpshore.com

On Fri, Dec 5, 2008 at 3:50 AM, Terion Miller wrote:

> Hey everyone I am still fighting the same problem that my script isn't
> working and its not reporting errors, when you click to "view" the work
> order it doesn't do anything, I have all kinds of error reporting turned on
> but nothing, do I have them syntax wrong?
>
> > include("inc/dbconn_open.php");
> error_reporting(E_ALL);
> ini_set('display_errors', '1');
> error_log("errors.txt");
>
>
> if (empty($_SESSION['AdminLogin']) OR $_SESSION['AdminLogin'] <> 'OK' ){
> header ("Location: LogOut.php");
> }
>
> if (isset($_GET['AdminID']) && !empty($_GET['AdminID'])){
> $AdminID = $_GET['AdminID'];
> } else {
> header ("Location: LogOut.php");
> }
>
> $query = "SELECT ViewAllWorkOrders FROM admin WHERE AdminID='$AdminID'";
> $result = mysql_query ($query);
> $row = mysql_fetch_object ($result);
> if ($row->ViewProjects == "NO") {
> header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry, you do
> not have access to that page.");
> }
>
> if (isset($_GET['WorkOrderID'])) {$WorkOrderID = $_GET['WorkOrderID'];}
> else
> {$WorkOrderID = '';}
> if (isset($_GET['ReturnPage'])) {$ReturnPage = $_GET['ReturnPage'];} else
> {$ReturnPage = 'Welcome.php';}
>
>
> $sql = "SELECT FormName FROM workorders WHERE
> WorkOrderID='$WorkOrderID'";
> $result = mysql_query ($sql);
> $row = mysql_fetch_object ($result);
>
>
> if (mysql_num_rows($result) > 0) {
>
> if ($row->FormName == "WorkOrder") {
> header ("Location:
>
> ViewWorkOrder.php?AdminID=$AdminID&WorkOrderID=$WorkOrderID&ReturnPage=$ReturnPage");
> }elseif ($row->FormName == "PD_Coupon") {
> header ("Location:
>
> ViewPD_Coupon.php?AdminID=$AdminID&WorkOrderID=$WorkOrderID&ReturnPage=$ReturnPage");
> }elseif ($row->FormName == "PD_TextAd") {
> header ("Location:
>
> ViewPD_TextAd.php?AdminID=$AdminID&WorkOrderID=$WorkOrderID&ReturnPage=$ReturnPage");
> }elseif ($row->FormName == "PD_Enhanced") {
> header ("Location:
>
> ViewPD_Enhanced.php?AdminID=$AdminID&WorkOrderID=$WorkOrderID&ReturnPage=$ReturnPage");
> }elseif ($row->FormName == "HS_Builder") {
> header ("Location:
>
> ViewHomescape_Builder.php?AdminID=$AdminID&WorkOrderID=$WorkOrderID&ReturnPage=$ReturnPage");
> }elseif ($row->FormName == "HS_SpecHome") {
> header ("Location:
>
> ViewHomescape_SpecHome.php?AdminID=$AdminID&WorkOrderID=$WorkOrderID&ReturnPage=$ReturnPage");
> } else {
> header ("Location: Welcome.php?AdminID=$AdminID&msg=Nothing
> works Does it....");
> }
> } else {
> header ("Location: Welcome.php?AdminID=$AdminID&msg=Nothing
> Works..grrrr");
> }
> ?>
>



--
Regards,
Johny
www.phpshore.com
Johny John
 
Posts: 2
Joined: Thu Dec 04, 2008 10:16 pm

Re: [PHP] Will not report errors what can I do

Postby Jim Lucas on Thu Dec 04, 2008 10:28 pm

Johny John wrote:
> HI Terion,
> Please put the error reporting on top of the page and try. If you have any
> errors in the include file, it won't execute the rest of commands. Make the
> changes to code as follows.
>
> > error_reporting(E_ALL);
> ini_set('display_errors', '1');
> include("inc/dbconn_open.php");
>
> ?>
>
> Regards,
>
> Johny John
>

This still doesn't address his possible parse error problem. If he has
a parse error, it makes no difference where he places the above lines.
Nothing is going to work.

It should be done via one of the three methods that mention in my other
email.

Jim Lucas
Jim Lucas
 
Posts: 625
Joined: Fri Jul 11, 2003 4:19 pm

Re: [PHP] Will not report errors what can I do

Postby Wolf on Fri Dec 05, 2008 12:04 am



Jim Lucas wrote:
> Johny John wrote:
>> HI Terion,
>> Please put the error reporting on top of the page and try. If you have
>> any
>> errors in the include file, it won't execute the rest of commands.
>> Make the
>> changes to code as follows.
>>
>> >> error_reporting(E_ALL);
>> ini_set('display_errors', '1');
>> include("inc/dbconn_open.php");
>>
>> ?>
>>
>> Regards,
>>
>> Johny John
>>
>
> This still doesn't address his possible parse error problem. If he has
> a parse error, it makes no difference where he places the above lines.
> Nothing is going to work.
>
> It should be done via one of the three methods that mention in my other
> email.

Putting it in the file is ideal if he can't set up his server to do it
via one of the other methods, however if he HAS set it up via other
methods, you normally HAVE to restart the server processes so that they
re-read the PHP.ini file so they actually will DO the changes that you
have made to them.

Otherwise you are just wasting more time.

HTH,
Wolf

Wolf
 
Posts: 155
Joined: Wed Oct 08, 2003 4:20 am


Return to PHP General Discussion (php.general)

Who is online

Users browsing this forum: No registered users and 0 guests