February 12, 2007 at 6:50 pm
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
February 12, 2007 at 7:08 pm
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
February 14, 2007 at 9:30 am
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
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply