bogaert-y Posted October 13, 2015 Share Posted October 13, 2015 (edited) HI guys, I have made a query in oci which works, the result should be a date format as in "2015-10-13" for example, the query can only return 1 "answer" however how can I get the result in a variable? the query is: $start = oci_parse($conn, " SELECT TO_CHAR(MIN(FLT_COM_DEP_BLK),'YYYY-MM-DD') FROM MASTER.FLIGHTS WHERE FLT_LFS_ID=100 AND INSTR(UPPER(FLT_TEXT_AS_SPECIAL),'_CID='||'$contractnr')>0 "); oci_execute($start); I want this result in a variable called $startd. thanks for the help. Yannick Edited October 13, 2015 by bogaert-y Quote Link to comment Share on other sites More sharing options...
hansford Posted October 13, 2015 Share Posted October 13, 2015 Same as fetching any other db record. Many fetch options. http://php.net/manual/en/function.oci-fetch-row.php while (($startd = oci_fetch_assoc($start)) != false) { // echo $startd['whatever']; } Quote Link to comment Share on other sites More sharing options...
bogaert-y Posted October 13, 2015 Author Share Posted October 13, 2015 thanks hansford, however still does not seem to be working the echo returns nothing. I have hardcoded a contract number in the query where I know it should return a value. Any idea's? Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted October 13, 2015 Share Posted October 13, 2015 is your code producing any php errors or any oci errors? is your code producing a completely blank page or does anything on the page get output to the browser and its just the query result that doesn't get output? if you read any of the 'help my page/query doesn't produce any output' posts on any of the php programming help forums, you will notice a common thread, displaying php errors and testing for and displaying database statement errors. you must ALWAYS have php's error_reporting set to E_ALL and for development/debugging display_errors should be set to ON. these two settings should be in the php.ini on your development system, so that they will report php parse/syntax errors and so that you don't need to remember to put them into the code you are developing/debugging. all the database statements that can fail due to an error (connection, prepare/parse, query/execute) must ALWAYS test for errors and handle them in a meaningful way. for development/debugging, you would want to display the database error information. next, queries that run successful can still match zero rows and in most cases you should use your database's num_rows function/method (see oci_num_rows()) to test for and handle this case. if your code was already was doing these things, it (your code) would be telling you if, where, and way it is failing. Quote Link to comment Share on other sites More sharing options...
hansford Posted October 13, 2015 Share Posted October 13, 2015 In addition to what mac_gyver stated, I would do a simple query on the same table and see if that returns any results as it may be simply not returning any rows based on the query. Quote Link to comment 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.