PHP/Oracle: Page hangs when trying to return too many rows

apinomus

Senior member
Dec 14, 2005
394
0
0
Unix-based server
Oracle 10g
PHP 5.1.4

I have three Oracle queries on the page, each their own function, to query and make a select drop-down. Two small boxes (less than 10 rows) and another large box (about 700 rows).

I also have a function (see below) that is used to check the auth status of the user. It is called once at the start of the page, and a second time in the body for a "User Box" where two session variables are printed back to the browser (user's name and another text string, both stored in session when they login).

On my winxp machine, Firefox and IE will both hang before drawing anything from the source if EITHER my large select box is trying to query too many rows (limit is like 7 or 8, very small) OR my is_authed() function is called again in the page. If I comment out the two small queries, I can return like 5 or 6 more rows in the large query before the browser will hang, but not anywhere near the max. I can return all results if I comment out one of the is_authed() checks.

Can any of you think of a reason this may be happening? Myself and co-workers thought it was a memory issue of some kind, but ini_set('memory_limit','16M') didn't help, so it must not be PHP's memory limit. register_globals is ON, but because of the system, ini_set('register_globals',0) and .htaccess attempts to change register_globals do not work.

Another weird thing is that once the browser hangs and won't load the page one time, I must delete my cookies before it will even load the scaled-back working version of the page.

If you would like to see more code to help diagnose the problem, please let me know.
 

Zugzwang152

Lifer
Oct 30, 2001
12,134
1
0
why do you need to check if the user is authenticated twice?

do it once, at the top of the page. then you can assume the user is authenticated.

I've never seen session_start() in a function. In general, you should put it at the very top of your script.
 

Drakkon

Diamond Member
Aug 14, 2001
8,401
1
0
are you using the oracle library? the oci8 library? odbc library?
I have oracle DB's of 10K rows returning all at once in php using the oci8 library and have no problems...although i get script timeouts if i dont set the processing time on the server really high :p
 

apinomus

Senior member
Dec 14, 2005
394
0
0
EDIT: Forgot, we recently upgraded to Oracle 10g, not 9i, and are using Unix-based servers.

@Zugzwang: In the left rail below the navigation is my "user box" that I want to include on every page that shows user-relivant info (their name and school they are affiliated with) along with user links such as "Edit Profile" and "Register For Events." If a user is not logged in, it shows a small username/password form where they can login. This "user box" script basically says, if(is_authed()) include 'user.php'; else include 'login_form.inc';

But on pages that require a login to even use, such as an Event Registration page, I am pulling data from the session ($_SESSION['user_id']) to then identify the user if they were to register for an event, and if no user_id is found in the session, redirect them to the login page via header(). The is_authed() function is called twice because (1) I am checking if the user is logged in to use the event registration page and (2) show their info in the "user box." Does this make sense or is there a better way to do this?

@Drakkon: I'm using a custom oci8 class written by a co-worker.