|
| Index | Recent Threads | Unanswered Threads | Who's Online | User List | Help |
|
|
| No member browsing this thread |
|
Thread Status: Active Total posts in this thread: 6
|
|
| Author |
|
|
Advanced Member Joined: May 26, 2006 Post Count: 1757 Status: Offline |
I'm working some PHP code that was written by somebody else. And I don't know why it's not working. Here is the page: http://library.tulane.edu/research/research_by_subject_test.php Basically when you go to the backend section and try to add another subject page, it does not show up. I thought that maybe this had something to do with the mySQL table not having enough space. I have attached a SS for a better explanation: ![]() You'll see where it says overhead and it a red number and it looks like the table has gone over it's size. Could this be the problem? Also, the person that wrote the code left a while ago and I can not get in touch with them: Here is the PHP code also: <?php /* DO NOT EDIT THIS AREA */ include('../include/includes_global/db_connect.php'); $r_width="5%"; $page_title = "Research: By subject"; include('../include/includes_global/breadcrumb.php'); include('../include/includes_global/header.php'); include('../include/includes_local/left_nav_research.php'); ?> <div class="content_header"><?php echo $page_title;?></div> <!-- Main Content Here --> <p> Below is a list of subjects with online databases available for your research. For <strong>online reference sources</strong> on topics ranging from art to science, visit our <a href="research/reference_sources.php">reference sources</a> page. The Library also has a large collection of print reference sources; for help in selecting these, ask for help at the <a href="about_the_library/departments/reference.php">Information & Reference Desk</a>.<br> <br> <p>This is the test area</p> <p></p> <p></p> <br> <br> <br> <br> <?php include('../include/includes_local/note_database_access.php'); function display_tree($root) { // retrieve the left and right value of the $root node $result = mysql_query('SELECT subject, lft, rgt, id, contact_1_id FROM subject WHERE subject="'.$root.'";'); $row = mysql_fetch_array($result); // start with an empty $right stack $right = array(); // now, retrieve all descendants of the $root node $result = mysql_query('SELECT subject, lft, rgt, id, contact_1_id FROM subject WHERE lft BETWEEN ' . $row['lft'] . ' AND ' . $row['rgt'] . ' ORDER BY lft ASC;'); // display each row while ($row = mysql_fetch_array($result)) { // only check stack if there is one if (count($right)>0) { // check if we should remove a node from the stack while ($right[count($right)-1]<$row['rgt']) { array_pop($right); } } if (strlen($row['contact_1_id'] > 0)) { // display indented node title //if it's Business, link directly to the Business site if ($row['id'] == "50") { echo str_repeat(' ',count($right))."<a href=\"http://www.freeman.tulane.edu/turchin\">" .$row['subject']."</a><br>"; } else if ($row['id'] !== "50") //if it's Latin American Studies, link directly to the Latin American Library if ($row['id'] == "51") { echo str_repeat(' ',count($right))."<a href=\"http://lal.tulane.edu\">" .$row['subject']."</a><br>"; } else if ($row['id'] !== "51") { echo str_repeat(' ',count($right))."<a href=\"research/subject_detail.php?id=" . $row['id'] . "\" title=\"" . $row['subject'] . "\">"; if (strlen($row['subject']) > 23) { echo substr($row['subject'],0,23) . "...</a><br>"; } else { echo $row['subject'] . "</a><br>"; } } } else { echo str_repeat(' ',count($right)) . "<strong>" . $row['subject']."</strong><br>"; } // add this node to the stack $right[] = $row['rgt']; } } ?> <br> <table cellpadding="4" cellspacing="1" border="0" width="100%"> <tr> <td valign="top" rowspan="2" class="content_table_white" width="33%"> <? display_tree('Arts & Humanities'); ?> </td> <td valign="top" rowspan="2" class="content_table_white" width="33%"> <? display_tree('Sciences & Engineering'); ?> </td> <td valign="top" class="content_table_white" width="33%"> <? display_tree('Social Sciences'); ?> </td> </tr> <tr> <td valign="top" class="content_table_white" width="33%"> <? display_tree('Interdisciplinary Studies'); ?> </td> </tr> </table> </p> <a href="<?php echo $_SERVER['REQUEST_URI'];?>#top"><img src="/images/return_to_top.gif" alt="Return to top of page" width="39" height="50" border="0" align="right"></a> <!-- End Main Content --> <? /* DO NOT EDIT THIS AREA */ include('../include/includes_local/right_nav_blank.php'); include('../include/includes_global/footer.php'); ?> ---------------------------------------- [Edit 1 times, last edit by admin at Dec 4, 2006 11:09:03 AM] |
||
|
|
Advanced Member Joined: Jun 14, 2003 Post Count: 2940 Status: Offline |
You should check for errors when you are trying to do anything with MySQL. The error message will give you a good idea of what is going on. For example: $result = mysql_query('SELECT subject, lft, rgt, id, contact_1_id FROM subject WHERE lft BETWEEN ' . $row['lft'] . ' AND ' . $row['rgt'] . ' ORDER BY lft ASC;'); if(!$result) { die("Ouch! My select statement didn't work. Ouch! -> " . mysql_error()); } The function: mysql_error(), will print out what is causing the problem. ---------------------------------------- Stefan Mischook Video Tutorial Store | Web Templates ---------------------------------------- [Edit 3 times, last edit by admin at Dec 4, 2006 11:15:41 AM] |
||
|
|
Member Joined: Sep 20, 2005 Post Count: 62 Status: Offline |
Overhead does not mean that the table has exceeded it's storage limitation. It simply implies that there are table columns/rows that are unoptimized. I don't know the exact formula for this but I'm pretty sure (please correct me if wrong here) normalizing your tables within the DB should almost eliminate overhead. You could also manually optimise the tables and remove the overhead. |
||
|
|
Advanced Member Joined: May 26, 2006 Post Count: 1757 Status: Offline |
@Stef, I've added the code to show me any errors, but all I get is a blank page. @Robbkore, thanks for the info. I've seen a couple of scripts that can be used to "optimize" your tables. I think I will use sometimes like this down the line. @Stef, here is my code again with the snippet that you gave me: <?php /* DO NOT EDIT THIS AREA */ include('../include/includes_global/db_connect.php'); $r_width="5%"; $page_title = "Research: By subject"; include('../include/includes_global/breadcrumb.php'); include('../include/includes_global/header.php'); include('../include/includes_local/left_nav_research.php'); ?> <div class="content_header"><?php echo $page_title;?></div> <!-- Main Content Here --> <p> Below is a list of subjects with online databases available for your research. For <strong>online reference sources</strong> on topics ranging from art to science, visit our <a href="research/reference_sources.php">reference sources</a> page. The Library also has a large collection of print reference sources; for help in selecting these, ask for help at the <a href="about_the_library/departments/reference.php">Information & Reference Desk</a>.<br> <br> <p>This is the test area</p> <p></p> <p></p> <br> <br> <br> <br> <?php include('../include/includes_local/note_database_access.php'); function display_tree($root) { // retrieve the left and right value of the $root node $result = mysql_query('SELECT subject, lft, rgt, id, contact_1_id FROM subject WHERE subject="'.$root.'";'); $row = mysql_fetch_array($result); // start with an empty $right stack $right = array(); // now, retrieve all descendants of the $root node $result = mysql_query('SELECT subject, lft, rgt, id, contact_1_id FROM subject WHERE lft BETWEEN ' . $row['lft'] . ' AND ' . $row['rgt'] . ' ORDER BY lft ASC;'); if(!$result) { die("Ouch! My select statement didn't work. Ouch! -> " . mysql_error()); // display each row while ($row = mysql_fetch_array($result)) { // only check stack if there is one if (count($right)>0) { // check if we should remove a node from the stack while ($right[count($right)-1]<$row['rgt']) { array_pop($right); } } if (strlen($row['contact_1_id'] > 0)) { // display indented node title //if it's Business, link directly to the Business site if ($row['id'] == "50") { echo str_repeat(' ',count($right))."<a href=\"http://www.freeman.tulane.edu/turchin\">" .$row['subject']."</a><br>"; } else if ($row['id'] !== "50") //if it's Latin American Studies, link directly to the Latin American Library if ($row['id'] == "51") { echo str_repeat(' ',count($right))."<a href=\"http://lal.tulane.edu\">" .$row['subject']."</a><br>"; } else if ($row['id'] !== "51") { echo str_repeat(' ',count($right))."<a href=\"research/subject_detail.php?id=" . $row['id'] . "\" title=\"" . $row['subject'] . "\">"; if (strlen($row['subject']) > 23) { echo substr($row['subject'],0,23) . "...</a><br>"; } else { echo $row['subject'] . "</a><br>"; } } } else { echo str_repeat(' ',count($right)) . "<strong>" . $row['subject']."</strong><br>"; } // add this node to the stack $right[] = $row['rgt']; } } ?> <br> <table cellpadding="4" cellspacing="1" border="0" width="100%"> <tr> <td valign="top" rowspan="2" class="content_table_white" width="33%"> <?php display_tree('Arts & Humanities'); ?> </td> <td valign="top" rowspan="2" class="content_table_white" width="33%"> <?php display_tree('Sciences & Engineering'); ?> </td> <td valign="top" class="content_table_white" width="33%"> <?php display_tree('Social Sciences'); ?> </td> </tr> <tr> <td valign="top" class="content_table_white" width="33%"> <?php display_tree('Interdisciplinary Studies'); ?> </td> </tr> </table> </p> <a href="<?php echo $_SERVER['REQUEST_URI'];?>#top"><img src="/images/return_to_top.gif" alt="Return to top of page" width="39" height="50" border="0" align="right"></a> <!-- End Main Content --> <? /* DO NOT EDIT THIS AREA */ include('../include/includes_local/right_nav_blank.php'); include('../include/includes_global/footer.php'); ?> ---------------------------------------- [Edit 1 times, last edit by admin at Dec 4, 2006 1:36:33 PM] |
||
|
|
Advanced Member Joined: Jun 14, 2003 Post Count: 2940 Status: Offline |
Please wrap your code in the post with the 'quote' option because using 'code' screws up the layout. Thanks. S ---------------------------------------- Stefan Mischook Video Tutorial Store | Web Templates |
||
|
|
Advanced Member Joined: May 26, 2006 Post Count: 1757 Status: Offline |
Oh, sorry bout that. Didn't mean to break the window. Buy any suggestions about code snippet you gave me. Could it be placed somewhere else inside the php code? Thanks. |
||
|
|
|
|
|
Current timezone is GMT May 21, 2013 8:05:00 AM |