Search function

  • i'm creating a website where i can search between 2 spesific dates which user will enter in the format of DD-MM-YYYY. the 2 dates will be inserted into 2 fields which is $input1 and $input2.

    heres my code:

    extract($_POST);

    //to set the date format

    //***************************

    $input1 = date('DD-MM-YYYY h:i:s');

    $input2 = date('DD-MM-YYYY h:i:s');

    $sql= "select TITLE,MAGIC,TIMEREG from title_table

    WHERE MAGIC in ('X', 'Y', 'Z')

    AND TIMEREG >= to_date('$input1','DD-MM-YYYY HH24:MI:SS')

    AND TIMEREG<= to_date('$input2','DD-MM-YYYY HH24:MI:SS')
    ;

    ***but i get the error message saying
    Warning: odbc_exec() [function.odbc-exec]: SQL error: [Oracle][ODBC]Option value changed., SQL state 01S02 in SQLExecDirect in C:\php\www\aaa\s_bbb.php on line 86
    Error in SQL statement

    please help..thx in advance

    Edit/Delete Message

  • SQLServerCentral is only for Microsoft SQL Server but you are connecting to an Oracle database!

    You are also using the function "to_date", which is proprietary to Oracle and has a different name in SQL Server.

    Try posting to one of the Oracle related sites, such as http://www.dbasupport.com/ or http://www.dbforums.com

    SQL = Scarcely Qualifies as a Language

  • Since I'm mostly a data troll, I don't know what language you are writing in, but I'll give it a shot even though this is Oracle...  replace the "&" with whatever the correct concatenation character is...

    extract($_POST);

    //to set the date format

    //***************************

    $input1 = date('DD-MM-YYYY h:i:s');

    $input2 = date('DD-MM-YYYY h:i:s');

    $sql= "select TITLE,MAGIC,TIMEREG from title_table

    WHERE MAGIC in ('X', 'Y', 'Z')

    AND TIMEREG >= to_date('" & $input1 & "','DD-MM-YYYY HH24:MI:SS')

    AND TIMEREG<= to_date('" & $input2 & "','DD-MM-YYYY HH24:MI:SS')

    ;"

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply