Solved

PHP code Spot the error

Posted on 2011-03-09
6
223 Views
Last Modified: 2012-06-21
Please take a look at the attached code. There is no error reported when I hit the URL, but no output shows up too. Even the ECHO or PRINT statement don't output anything.

Can you please help me find out what the issue is?
<?php

	// Setup
	$testing = true; // in development
	require_once(dirname(__FILE__).'/../config.inc');
	$db = new OCIDatabase();
	// Start/End dates
	if($testing)
	{
		$yesterday = mktime(0, 0, 0, 12, 27,   2010); // determin what yesterday was
		$now = time();
		//$now = mktime(0, 0, 0, 12, 28,   2010); // determin what yesterday was
	}
	else
	{
		$yesterday = mktime(0, 0, 0, date('m'), date('d')-1,   date('Y')); // determin what yesterday was
		$now = time();
	}

// 1. send QES log[report] emails to IT address(es)
	// - select ClientId,TableName,Count from admin_log_qes order by TableName,clientid
	$reports_sql = "Select log.ClientId,log.TableName,log.Count 
					From 
						admin_log_qes log 
					Where 
						log.logstamp >= TO_TIMESTAMP('".date('d', $yesterday).".".date('m', $yesterday).".".date('Y', $yesterday).":18:00:00','DD.MM.YYYY:HH24:MI:SS') 
						AND 
						log.logstamp < TO_TIMESTAMP('".date('d', $now).".".date('m', $now).".".date('Y', $now).":".date('H', $now).":".date('i', $now).":00','DD.MM.YYYY:HH24:MI:SS')";

	Print "Test";

	if($db->select($reports_sql))
	{
		$message = "Report logs from " . date("m/d/Y H:i", strtotime("-24 hours")) . " to " . date("m/d/Y H:i") . ":\n\n";
		while($log = $db->fetch_assoc())
		{
			$message .= " --" . $log['TABLENAME'] . "\n";
		}
		if($testing)
		{
			echo $message . "\n\n";
			//Util::sendEMail(EMAIL_IT, "no-reply@" . $_SERVER['HTTP_HOST'], 'Report Logs', $message);
		}
		else
		{
			Util::sendEMail(EMAIL_IT, "no-reply@" . $_SERVER['HTTP_HOST'], 'Report Logs', $message);
		}
	}

?>

Open in new window

0
Comment
Question by:codemonkey2480
  • 2
  • 2
  • 2
6 Comments
 
LVL 13

Expert Comment

by:darren-w-
ID: 35084011
Its defiantly on line 30 onwards, assuming  that the  OCIDatabase(); object is created correctly?

Darren
0
 

Author Comment

by:codemonkey2480
ID: 35084119
How do I find out? I have not worked with PHP much.
0
 
LVL 13

Expert Comment

by:darren-w-
ID: 35084210
add between lines 6/7

if (!is_object($db)) {
        die("no object");
    }

Open in new window

0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 34

Accepted Solution

by:
Beverley Portlock earned 500 total points
ID: 35086070
Add these lines

ini_set('display_errors',1);
error_reporting( E_ALL );

at the very start of your script after the first <?php tag and see what errors show up
0
 
LVL 34

Expert Comment

by:Beverley Portlock
ID: 35086072
Also, if you have access, check your server's error logs
0
 

Author Closing Comment

by:codemonkey2480
ID: 35086302
added these 2 lines
ini_set('display_errors',1);
error_reporting( E_ALL );

and found out there was an issue referencing a config file.

Fixed the issue.

thanks all.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now