Jump to content

[SOLVED] It works in Apex but not in PHP?


Recommended Posts

When I run the following from my php application/script I find that I get no data back but when I run just the SQL statement in Database Express' SQL Command console (Apex) I get good data back.

$StartDate="2006/01/01 06:00:00";

 

$EndDate="2007/09/29 6:00:00";

$SQL = "SELECT TRANS_TABLE_NAME, SUM(TRANS_TURNOVER) TotalTurnover FROM TRANSACT

where (TRANS_CODE = '$number' AND

(TRANS_DATE BETWEEN TO_DATE('$StartDate','YYYY/MM/DD HH24:MI:SS') AND TO_DATE('$EndDate','YYYY/MM/DD HH24:MI:SS')))

GROUP BY TRANS_TABLE_NAME;";

 

        $stmt = OCIParse($conn, $SQL );

 

        OCIExecute($stmt);

 

// echo $SQL;

 

$Count = 0;

while (OCIFetch($stmt))

{

  echo "COL1=" . ociresult($stmt, "COL1") .

    ", COL2=" . ociresult($stmt, "COL2") . "\n";

$Count++;

 

  }

if ($Count == 0)

 

            {

    print "\nError code = "    . ora_errorcode();

    print "\nError message = " . ora_error();

 

            $Message = sprintf("No play by [%s] found! ", $number);

 

            trigger_error($Message, E_USER_ERROR);

 

            die();

 

            }

 

 

Please tell me what I have got wrong.

Link to comment
Share on other sites

cj in the PHP forum on the Oracle site <http://forums.oracle.com/forums/thread.jspa?messageID=2003652&#2003652> recommended var_dump($stmt) after the parse.

var_dump($stmt) returns:-

resource(18) of type (oci8 statement) which, as a nooby to Oracle, I really do not understand.

 

but his suggestion of removing the semi-colon at the end of the command line has certainly given me a different result with which I can now go forward with.

Thank you cj.

 

Link to comment
Share on other sites

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.