rbragg Posted August 21, 2007 Share Posted August 21, 2007 What is the OCI equivalent to mysql_fetch_array in SQL+? I am using PHP 4 and so oci_ fetch_ array does not work for me. <?php $queryHall = " SELECT hall FROM user.hall "; $hallResults = ociparse($connect, $queryHall); ociexecute($hallResults); echo "<select name='hallDrop'>"; echo "<option value=' '> </option>"; while( $hall = ocifetch($hallResults) ) { echo " \n\t<option value = '" . $hall . "'"; if (isset($_SESSION['hallDrop']) && $_SESSION['hallDrop'] == $hallList) { echo " selected='selected' "; } echo ">" . $hall . "</option>"; } echo "</select>"; ?> My droplist is not populated. :-\ Inserting $hallList = ociresult($hall,"HALL"); is of no help either. Quote Link to comment https://forums.phpfreaks.com/topic/65974-solved-need-alternative-to-oci_fetch_array-for-php-4/ Share on other sites More sharing options...
MadTechie Posted August 21, 2007 Share Posted August 21, 2007 would $hall be $hall['user'] ? Quote Link to comment https://forums.phpfreaks.com/topic/65974-solved-need-alternative-to-oci_fetch_array-for-php-4/#findComment-329874 Share on other sites More sharing options...
rbragg Posted August 21, 2007 Author Share Posted August 21, 2007 Thanks for your reply. In user.hall, user is my schema and hall is my table. Quote Link to comment https://forums.phpfreaks.com/topic/65974-solved-need-alternative-to-oci_fetch_array-for-php-4/#findComment-329914 Share on other sites More sharing options...
MadTechie Posted August 21, 2007 Share Posted August 21, 2007 oops i mean should't $hall be $hall['hall'] ? as $hall would be the recordset and the field inside that set would be hall Quote Link to comment https://forums.phpfreaks.com/topic/65974-solved-need-alternative-to-oci_fetch_array-for-php-4/#findComment-329918 Share on other sites More sharing options...
rbragg Posted August 21, 2007 Author Share Posted August 21, 2007 I should say that I usually program in mySQL and am learning SQL+/Oracle. I had read that when you use ocifetch, you must also use ociresult. That's why I had mentioned the $hallList = ociresult($hall,"HALL"); and using $hallList as the record set. I did try the field referencing and it did not work: <?php $hallResults = ociparse($connect, $queryHall); ociexecute($hallResults); echo "<select name='hallDrop'>"; echo "<option value=' '> </option>"; while( $hall = ocifetch($hallResults) ) { echo " \n\t<option value = '" . $hall['HALL'] . "'"; if (isset($_SESSION['hallDrop']) && $_SESSION['hallDrop'] == $hall['HALL']) { echo " selected='selected' "; } echo ">" . $hall['HALL'] . "</option>"; } echo "</select>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/65974-solved-need-alternative-to-oci_fetch_array-for-php-4/#findComment-329927 Share on other sites More sharing options...
MadTechie Posted August 21, 2007 Share Posted August 21, 2007 can you do a print_r($hall); just above echo " \n\t<option value = '" . $hall['HALL'] . "'"; and post the results Quote Link to comment https://forums.phpfreaks.com/topic/65974-solved-need-alternative-to-oci_fetch_array-for-php-4/#findComment-329948 Share on other sites More sharing options...
rbragg Posted August 21, 2007 Author Share Posted August 21, 2007 Hi! I added the <?php print_r($hall); ?> and still have an empty drop list and no printed values anywhere. I have looked in the error logs and there are none. ??? Quote Link to comment https://forums.phpfreaks.com/topic/65974-solved-need-alternative-to-oci_fetch_array-for-php-4/#findComment-329979 Share on other sites More sharing options...
MadTechie Posted August 21, 2007 Share Posted August 21, 2007 try this (lots of commenting out) whats displayed <?php $queryHall = " SELECT hall FROM user.hall "; $hallResults = ociparse($connect, $queryHall); ociexecute($hallResults); //echo "<select name='hallDrop'>"; //echo "<option value=' '> </option>"; while( $hall = ocifetch($hallResults) ) { print_r($hall); //echo " \n\t<option value = '" . $hall . "'"; //if (isset($_SESSION['hallDrop']) && $_SESSION['hallDrop'] == $hallList) //{ // echo " selected='selected' "; //} //echo ">" . $hall . "</option>"; } echo "</select>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/65974-solved-need-alternative-to-oci_fetch_array-for-php-4/#findComment-330048 Share on other sites More sharing options...
rbragg Posted August 21, 2007 Author Share Posted August 21, 2007 Making progress - I get: 11111111111 There are eleven values in my db in the HALL field, which I imagine is why there are eleven 1's. Quote Link to comment https://forums.phpfreaks.com/topic/65974-solved-need-alternative-to-oci_fetch_array-for-php-4/#findComment-330060 Share on other sites More sharing options...
lemmin Posted August 21, 2007 Share Posted August 21, 2007 You should be able to use the same code you have but change your ocifetch() function to ocifetchinto(). This gets the row and puts the ocntents into an array. If it doesn't work, do a print_r() again to see what exactly is in that array. EDIT: actually you have to change the syntax a little bit because ocifetchinto() accepts a pointer to an array to put the contents into: http://us2.php.net/manual/en/function.ocifetchinto.php Quote Link to comment https://forums.phpfreaks.com/topic/65974-solved-need-alternative-to-oci_fetch_array-for-php-4/#findComment-330062 Share on other sites More sharing options...
rbragg Posted August 21, 2007 Author Share Posted August 21, 2007 <?php while (ocifetchinto($hallResults, $hall, OCI_ASSOC)) ?> Unfortunately, oic_assoc is not a function that is available in PHP 4. When I use the above syntax, I get eleven instances of the word "Array". Quote Link to comment https://forums.phpfreaks.com/topic/65974-solved-need-alternative-to-oci_fetch_array-for-php-4/#findComment-330141 Share on other sites More sharing options...
lemmin Posted August 21, 2007 Share Posted August 21, 2007 Try leaving the mode as default: <?php while (ocifetchinto($hallResults, $hall)) ?> Quote Link to comment https://forums.phpfreaks.com/topic/65974-solved-need-alternative-to-oci_fetch_array-for-php-4/#findComment-330147 Share on other sites More sharing options...
rbragg Posted August 21, 2007 Author Share Posted August 21, 2007 Btw, thanks for your assistance also. This still gives the Array instances. Quote Link to comment https://forums.phpfreaks.com/topic/65974-solved-need-alternative-to-oci_fetch_array-for-php-4/#findComment-330154 Share on other sites More sharing options...
lemmin Posted August 21, 2007 Share Posted August 21, 2007 How about something like this: $connect = OCILogOn("user", "password", $db); $query = "SELECT * total FROM table"; $parse = OCIParse($connect, $query); OCIExecute($parse); OCIFetch($parse); echo OCIResult($parse, "field"); Quote Link to comment https://forums.phpfreaks.com/topic/65974-solved-need-alternative-to-oci_fetch_array-for-php-4/#findComment-330168 Share on other sites More sharing options...
rbragg Posted August 21, 2007 Author Share Posted August 21, 2007 I did exactly that early on. As I stated above, I once tried using the ociresult function with ocifetch like this: <?php ociexecute($hallResults); while( $hall = ocifetch($hallResults) ) { $hallList = ociresult($hall,"HALL"); blah blah } ?> Quote Link to comment https://forums.phpfreaks.com/topic/65974-solved-need-alternative-to-oci_fetch_array-for-php-4/#findComment-330198 Share on other sites More sharing options...
lemmin Posted August 21, 2007 Share Posted August 21, 2007 What does the ociresult return when you do it? Maybe you should do some "or die(print_r(ocierror()));" for all of your oci commands and see if there is an error somewhere. Quote Link to comment https://forums.phpfreaks.com/topic/65974-solved-need-alternative-to-oci_fetch_array-for-php-4/#findComment-330257 Share on other sites More sharing options...
rbragg Posted August 21, 2007 Author Share Posted August 21, 2007 Our server has error printing turned off. I have access to the logs on the server and I don't get any errors. When I print ociresult($hall, "HALL") my droplist is empty. That was square 1. :-X Thanks for trying. Quote Link to comment https://forums.phpfreaks.com/topic/65974-solved-need-alternative-to-oci_fetch_array-for-php-4/#findComment-330324 Share on other sites More sharing options...
lemmin Posted August 21, 2007 Share Posted August 21, 2007 Just a guess here, but what if you change your query from $queryHall = " SELECT hall FROM user.hall "; to: $queryHall = " SELECT hall FROM user "; Assuming, of course, that user is the name of your table and not your database. Quote Link to comment https://forums.phpfreaks.com/topic/65974-solved-need-alternative-to-oci_fetch_array-for-php-4/#findComment-330338 Share on other sites More sharing options...
rbragg Posted August 21, 2007 Author Share Posted August 21, 2007 I replied to MadTechie with: In user.hall, user is my schema and hall is my table. Quote Link to comment https://forums.phpfreaks.com/topic/65974-solved-need-alternative-to-oci_fetch_array-for-php-4/#findComment-330351 Share on other sites More sharing options...
lemmin Posted August 21, 2007 Share Posted August 21, 2007 Sorry, I didn't see that. Are you also selecting the database when you connect? If so, try to do just "FROM hall". The only reason I suggest such things is that it would seem that your php can't be much different so I figure there is a chance that something is wrong with the query. Access or other programs might require the shema be included in the query, but, since you are selecting it in the connection (probably), it would seem redundant. If nothing else, it might help in debugging. Quote Link to comment https://forums.phpfreaks.com/topic/65974-solved-need-alternative-to-oci_fetch_array-for-php-4/#findComment-330379 Share on other sites More sharing options...
MadTechie Posted August 22, 2007 Share Posted August 22, 2007 what about this <?php $queryHall = " SELECT hall FROM user.hall "; $hallResults = ociparse($connect, $queryHall); ociexecute($hallResults); echo "<select name='hallDrop'>"; echo "<option value=' '> </option>"; while( $hall = ocifetch($hallResults) ) { $hall = ociresult($hallResults, "HALL"); //added echo " \n\t<option value = '" . $hall . "'"; if (isset($_SESSION['hallDrop']) && $_SESSION['hallDrop'] == $hallList) { echo " selected='selected' "; } echo ">" . $hall . "</option>"; } echo "</select>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/65974-solved-need-alternative-to-oci_fetch_array-for-php-4/#findComment-330678 Share on other sites More sharing options...
rbragg Posted August 22, 2007 Author Share Posted August 22, 2007 Thank you MadTechie! The problem was that I had: $hallList = ociresult($hall,"HALL"); instead of: $hallList = ociresult($hallResults,"HALL"); :-X By the way, I also changed: while( $hall = ocifetch($hallResults) ) back to: while( ocifetch($hallResults) ) Quote Link to comment https://forums.phpfreaks.com/topic/65974-solved-need-alternative-to-oci_fetch_array-for-php-4/#findComment-330895 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.