iPixel Posted July 30, 2010 Share Posted July 30, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/209365-why-am-i-not-getting-a-result/ Share on other sites More sharing options...
wildteen88 Posted July 30, 2010 Share Posted July 30, 2010 After this line $etime_res = oci_fetch_assoc($etime_go); do echo "<pre>" . print_r($etime_res, true) . "</pre>"; What is the output? Quote Link to comment https://forums.phpfreaks.com/topic/209365-why-am-i-not-getting-a-result/#findComment-1093226 Share on other sites More sharing options...
iPixel Posted July 30, 2010 Author Share Posted July 30, 2010 I dont get an output... nothing get's echo'ed. Quote Link to comment https://forums.phpfreaks.com/topic/209365-why-am-i-not-getting-a-result/#findComment-1093257 Share on other sites More sharing options...
wildteen88 Posted July 30, 2010 Share Posted July 30, 2010 At the top of your script add the following error_reporting(E_ALL); ini_set('display_error', true); Post the error(s) you get. White blank page usually indicates there is a fatal error. Quote Link to comment https://forums.phpfreaks.com/topic/209365-why-am-i-not-getting-a-result/#findComment-1093259 Share on other sites More sharing options...
iPixel Posted July 30, 2010 Author Share Posted July 30, 2010 No errors at all. Quote Link to comment https://forums.phpfreaks.com/topic/209365-why-am-i-not-getting-a-result/#findComment-1093261 Share on other sites More sharing options...
wildteen88 Posted July 30, 2010 Share Posted July 30, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/209365-why-am-i-not-getting-a-result/#findComment-1093267 Share on other sites More sharing options...
iPixel Posted July 30, 2010 Author Share Posted July 30, 2010 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 = "--"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/209365-why-am-i-not-getting-a-result/#findComment-1093270 Share on other sites More sharing options...
iPixel Posted July 30, 2010 Author Share Posted July 30, 2010 ok all of a sudden the echo/prin_r worked... here's what comes out Array ( [PUNCH_IN] => 8:52AM ) Quote Link to comment https://forums.phpfreaks.com/topic/209365-why-am-i-not-getting-a-result/#findComment-1093272 Share on other sites More sharing options...
wildteen88 Posted July 30, 2010 Share Posted July 30, 2010 The only problem I see with the code is, $time = $etime_res['$etime_col']; Should be $time = $etime_res[$etime_col]; Quote Link to comment https://forums.phpfreaks.com/topic/209365-why-am-i-not-getting-a-result/#findComment-1093273 Share on other sites More sharing options...
iPixel Posted July 30, 2010 Author Share Posted July 30, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/209365-why-am-i-not-getting-a-result/#findComment-1093275 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.