473,386 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Page don't load - using odbc and Access db

I'm using ODBC to read a office access db

the db have almost 10,000 rows so I want to split it into pages

The first page load nice and quick, but in other pages i get:

Expand|Select|Wrap|Line Numbers
  1. Maximum execution time of 30 seconds exceeded in c:\apache\htdocs\eyal\new.php on line 100
the line 100 is the odbc_exec command.

in the top of the page i get:

Expand|Select|Wrap|Line Numbers
  1. Warning: Use of undefined constant id - assumed 'id' in c:\apache\htdocs\eyal\new.php on line 7
  2. Warning: Use of undefined constant pname - assumed 'pname' in c:\apache\htdocs\eyal\new.php on line 8
  3. Warning: Use of undefined constant lname - assumed 'lname' in c:\apache\htdocs\eyal\new.php on line 9
  4. Warning: Use of undefined constant addr - assumed 'addr' in c:\apache\htdocs\eyal\new.php on line 10
  5. Warning: Use of undefined constant city - assumed 'city' in c:\apache\htdocs\eyal\new.php on line 11
  6. Warning: Use of undefined constant phone - assumed 'phone' in c:\apache\htdocs\eyal\new.php on line 12
  7. Warning: Use of undefined constant cphone - assumed 'cphone' in c:\apache\htdocs\eyal\new.php on line 13
  8. Warning: Use of undefined constant jdate - assumed 'jdate' in c:\apache\htdocs\eyal\new.php on line 14
the lines:
Expand|Select|Wrap|Line Numbers
  1.   $fields = array(id => "מספר כרטיס",
  2.                   pname => "שם פרטי:",
  3.                   lname => "שם משפחה:",
  4.                   addr => "כתובת:",
  5.                   city => "עיר מגורים:",
  6.                   phone => "מספר טלפון:",
  7.                   cphone => "מספר פלאפון:",
  8.                   jdate => "תאריך הצטרפות:");
  9.  
the main of my code:

Expand|Select|Wrap|Line Numbers
  1. switch ($do) {
  2.     case "list":
  3.         if ($page > 0) {
  4.             $npage = $page + 1;
  5.             $ppage = $page - 1;
  6.         }
  7.         else {
  8.             $page = 0;
  9.             $npage = 1;
  10.         }
  11.         $gpage = $page * 50;
  12.         print("<table dir=\"rtl\" cellspacing=0 cellpadding=5>
  13.                <tr dir=\"rtl\">");
  14.         foreach ($fields as $key => $value) {
  15.             $value = str_replace(":", " ", $value); 
  16.             print("<th class=main>$value</th>");
  17.         }
  18.         print("<th class=endmain>ניהול</th>
  19.                </tr>");
  20.         if ($gpage == 0) {
  21.             $sql_query = "SELECT TOP 50 * FROM tbl_clients";
  22.         }
  23.         else {
  24.             $sql_query = "SELECT TOP 50 * FROM tbl_clients where ( ID NOT IN ( SELECT TOP $gpage id FROM tbl_clients ORDER BY id ASC ) ) ORDER BY id ASC";
  25.         }
  26.         $do_query = odbc_exec($conn, $sql_query);                               
  27.         while (odbc_fetch_row($do_query)) {
  28.             print("<tr>");
  29.             foreach ($fields as $key => $value) {
  30.                 $text = odbc_result($do_query,$key);
  31.                 if ($key == "id") { $text = round($text); }
  32.                 if($key == "jdate") { $text = ereg_replace(" 00:00:00" , "", $text); }
  33.                 print("<td class=main>&nbsp;$text</td>");
  34.             }
  35.             print("<td class=endmain>&nbsp;" . dolink("$_SERVER[PHP_SELF]?do=edit", "עריכה"));
  36.             print("</tr>");  
  37.         }
  38.         print("<tr>");
  39.         if (empty($page) OR !isset($page)) {
  40.             $form = $_SERVER['QUERY_STRING'];
  41.             if ($page == 0) {
  42.                 $form = ereg_replace("page=0", "page=$npage", $form);
  43.  
  44.             }
  45.             else {
  46.                 $form .= "&page=1";
  47.             }
  48.             echo $form;
  49.             print("<td>");
  50.             pp($form, "next");
  51.             print("</td>");
  52.         }
  53.         else {
  54.             if ($page > 0) {
  55.                 $form = $_SERVER[QUERY_STRING];
  56.                 $form = ereg_replace("page=$page", "page=$ppage", $form);
  57.                 print("<td>");
  58.                 pp($form, "prev");
  59.                 print("</td>");
  60.             }
  61.             print("<td>&nbsp;</td>");
  62.             if (($page > 0) AND ($page < $count)) {
  63.                 $form = $_SERVER[QUERY_STRING];
  64.                 $form = ereg_replace("page=$page", "page=$npage", $form);
  65.                 print("<td>");
  66.                 pp($form, "next");
  67.                 print("</td>");
  68.             }
  69.         }
  70.         print("</tr>");
  71.         doexit();                   
  72. }
  73.  
Help

Thanks :)
Oct 17 '08 #1
5 2240
Markus
6,050 Expert 4TB
You could set the time limit of a page so that your script doesn't time out.
Oct 17 '08 #2
That helps, thanks.

But why is it taking so long (about 3 min) for the page to load?

I don't think it's my comp... duel core with 2gb ram...

maybe something in the code?
Oct 17 '08 #3
Atli
5,058 Expert 4TB
Hi.

First, your array keys are defined incorrectly. Assuming they are meant to be strings, they should be quoted.
Expand|Select|Wrap|Line Numbers
  1. // This is incorrect. It will try to load the value for the
  2. // constant named id, but if it fails to find it, it will
  3. // assume it was meant to be a string and show a warning.
  4. $arr = array(id => 'some value');
  5.  
  6. // This is how it should be done
  7. $arr = array('id' => 'some value'); //Correct
  8.  
As to the execution time, I would assume it is database related. The PHP code itself should not take anywhere near that long to execute.
The SQL query, however, could be taking some time on a large table. Especially if that table was not designed for such a query on a large amount of data.

How to fix such a problem I do not know. I don't know enough about Access to really know that. Maybe it has something to do with the sub-query? I know they can cause performance issues on other SQL servers.
Oct 18 '08 #4
Thanks, it solved my array error.

Do you know another way for me to use instead of sub-query?

I searched google alot to find this solution for paging in mssql.
Oct 18 '08 #5
Okay do I decided to do the page system the "long" way: selecting all the db and just printing the "right" page.

The problem now is that It's skipping rows (id 1, 3, 5, 7 and so on)

Here's the code:

Expand|Select|Wrap|Line Numbers
  1.         if ($page > 0) {
  2.             $npage = $page + 1;
  3.             $ppage = $page - 1;
  4.         }
  5.         else {      
  6.             $page = 0;
  7.             $npage = 1;
  8.         } 
  9.         $gpage = $page * 50;
  10.         print("<table dir=\"rtl\" cellspacing=0 cellpadding=5>
  11.                <tr dir=\"rtl\">");
  12.         foreach ($fields as $key => $value) {
  13.             $value = str_replace(":", " ", $value); 
  14.             print("<th class=main>$value</th>");
  15.         }
  16.         print("<th class=endmain>ניהול</th>
  17.                </tr>");
  18.         $sql_query = "SELECT * FROM tbl_clients ORDER BY id ASC";
  19.         $do_query = odbc_exec($conn, $sql_query);
  20.         $target = $gpage + 50;
  21.         $row_count = 0;
  22.         while (odbc_fetch_row($do_query)) {
  23.             if ($row_count < $gpage) {
  24.                 $row_count++;
  25.                 continue;
  26.             }
  27.             else {
  28.                 if ($gpage < $target) {
  29.                     print("<tr>");
  30.                     foreach ($fields as $key => $value) {
  31.                         $text = odbc_result($do_query,$key);
  32.                         if ($key == "id") { $text = round($text); }
  33.                         if($key == "jdate") { $text = ereg_replace(" 00:00:00" , "", $text); }
  34.                         print("<td class=main>&nbsp;$text</td>");
  35.                     }
  36.                     print("<td class=endmain>&nbsp;" . dolink("$_SERVER[PHP_SELF]?do=edit", "עריכה"));
  37.                     print("</tr>");
  38.                     $gpage++;
  39.                 }
  40.                 else if ($gpage > $target) {
  41.                     break;
  42.                 }
  43.             }
  44.         }
  45.  
Why?

Thanks :)
Oct 20 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: WindAndWaves | last post by:
Hi Gurus I am keen to make a search page on a website, but I have absolutely zero experience with PHP. I am going to hire an expert, but I thought that it may pay to try it a bit first myself...
11
by: Wolfgang Kaml | last post by:
Hello All, I have been working on this for almost a week now and I haven't anything up my sleeves anymore that I could test in addition or change.... Since I am not sure, if this is a Windows...
6
by: Paul Robinson | last post by:
I am developing a website in ASP that connects to a Sybase database. However, when I try to open a connection to the database the page will not load. The script does not timeout, nor the...
1
by: Eirik Tryggeseth | last post by:
During deployment of an application using distributed transactions managed under COM+ on an Oracle 9i RAC database, we encounter situations where the load balancing mechanisms in the RAC result in...
6
by: martin | last post by:
Hi, I am a web page and a web user control. My web user control is placed in my web page using the following directive <%@ Register TagPrefix="uc1" TagName="Header"...
18
by: J-T | last post by:
Hi All, There is a picture on the following URL which I want to have it in one of my asp.net pages .I mean I want to embed the content of this page in my own page and get its image.Is there a...
6
by: abcd | last post by:
I have asp.net web page written in C# it works great on Windows XP. Now I am testing that on Windows 2K. For that I have set a virtual machine and it has W2K with SP4 and .net runtime ... The...
11
by: frizzle | last post by:
Hi there, I need a function to prevent a page from being loaded too often too fast. So say, one is only allowed to refresh a single page 5 times in 10 seconds, or 10 times in 5 seconds (or...
3
by: Harmony504 | last post by:
HELP! Setup: PHP5.2.5, IIS 5.1, XP, AS/400 (DB/400 or DB2) I am trying to connect to a DB2 database from my computer. I installed DB2 Connect and set up the ODBC Driver in the Data Source...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.