Jump to content

Recommended Posts

Ok i call a function like so ...

<?php PunchTime($monday,"in","1",$etime_who); ?>

 

Below is the function, if you look closely i echo the query after it's been ran, and that query works 100% since i copied & pasted the query into the database and it returns a result that's needed. But for some bloody reason it doesn't work via code.

function PunchTime($pdate,$type,$num,$ewho)
{
	if($type == "in")
		{
			if($num == "1")
				{
					$etime_col = "PUNCH_IN";
				}
			elseif($num == "2")
				{
					$etime_col = "PUNCH_IN2";
				}
		}
	elseif($type == "out")
		{
			if($num == "1")
				{
					$etime_col = "PUNCH_OUT";
				}
			elseif($num == "2")
				{
					$etime_col = "PUNCH_OUT2";
				}
		}

	include_once('oracleCON.php');

	$etime_qry = "SELECT $etime_col FROM tablename WHERE who= '$ewho' AND punch_date = '$pdate'";
	echo $etime_qry;
	$etime_go = oci_parse($conn, $etime_qry);
	oci_execute($etime_go);
	$etime_res = oci_fetch_assoc($etime_go);

	$time = $etime_res[$etime_col];
	if($time == "") $time = "--";

	echo $time;
}

 

All i get are "--" even though some should return a time stamp.

Link to comment
https://forums.phpfreaks.com/topic/209365-why-am-i-not-getting-a-result/
Share on other sites

No errors at all.

Sorry forgot to mention make sure those lines are in the script where you are calling your function, not where you are defining it (incase your function definition is in a different file).

 

and that query works 100% since i copied & pasted the query into the database and it returns a result that's needed

What happens when you replace this

$etime_qry = "SELECT $etime_col FROM tablename WHERE who= '$ewho' AND punch_date = '$pdate'";

With the query that worked.

The function that is being called is in the same file... when i replace the query variables with what should be there it still fails for some reason... but that same query works just fine via oracle gui.

 

I'm almost certain whatever issue there is lies in these lines.

 

<?php
$etime_go = oci_parse($conn, $etime_qry);
					oci_execute($etime_go);
					$etime_res = oci_fetch_assoc($etime_go);

					#echo "<pre>" . print_r($etime_res, true) . "</pre>";

					$time = $etime_res['$etime_col'];
					if($time == "") $time = "--";
?>

OMG!!!!!!! I swear i didnt change a thing and all of a sudden it started working!!! God damn waste of time geez! Thanks guys for the help!....

 

Ooops slight lie, instead of calling the file oracleCON.php i simply took the code and embeded it into the function i guess that did the trick.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.