views:

45

answers:

2

Here the code:

<?php
include_once 'config.php';
// Connect to database
$conn = oci_connect($dbuser, $dbpasswd, $dbhost."/".$dbname);
if (!$conn) {
    exit ("Connection failed.");
}

$id = isset($_GET['id']) ? (int)$_GET['id'] : false;
$type = isset($_GET['type']) ? strtoupper($_GET['type']) : "BLOG";

$stmt = oci_parse($conn, 
    "begin 
    PKG_LIKE.get_LikeId(
    :I_N_Id,
    :I_S_Type,
    :O_N_grade,
    :O_N_exitFlag,
    :O_S_exitMsg);
    end;");
oci_bind_by_name($stmt, "I_N_Id", $id);
oci_bind_by_name($stmt, "I_S_Type", $type);

oci_bind_by_name($stmt, "O_N_grade", $total);
oci_bind_by_name($stmt, "O_N_exitFlag", $flag);
oci_bind_by_name($stmt, "O_S_exitMsg", $message);

if (!oci_execute($stmt)) {
    exit("Procedure Failed.");
}

if ($message == 'OK') {
    $response = array('likeit' => $total);
    $toReturn = "var response=".json_encode($response)."; showTotalLikeit(response);";
} else {
    $response = array('likeit' => 'NaN', 'exitFlag' => $flag, 'exitMsg' => $message);
    $toReturn = "var response=".json_encode($response)."; showTotalLikeit(response);";
}

print $toReturn;
?>

Result is "Procedure Failed". Where i'm failing? I've just use stored procedure call (but with cursors as output) till now and all go fine :|

Launching the SP on Oracle works fine so it's a php problem :S

+1  A: 
if (oci_execute($stmt)) {
    exit("Procedure Failed.");
}

So, your logic is: if the execute is successful, then the procedure failed?

Just replace with:

if (!oci_execute($stmt)) {
   exit("Procedure Failed.");
}
narcisradu
... i need to sleep.Anyway now the page print correctly "procedure failed"...So, what's wrong? ^^(going to edit the question)
theCrius
I can't replicate because I don't have Oracle here but can you try to see if oci_bind_by_name returns true or false?
narcisradu
Checking:All TRUE.And oci_parse, return the resource id.
theCrius
A: 

Magically it works while i was debugging using some echo to print the content of some variables.

I'm sure i've to kill a SysAdmin for these days wasted.

theCrius