Killersites.com Homepage Welcome Guest   |   Register  |  Login
Login Name Password
  Search  
  Index  | Recent Threads  | Unanswered Threads  | Who's Online  | User List  | Help


Quick Go »

No member browsing this thread
Thread Status: Active
Total posts in this thread: 6
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 883 times and has 5 replies Next Thread
Male cboudy
Advanced Member
Member's Avatar


Joined: May 26, 2006
Post Count: 1757
Status: Offline
Reply to this Post  Reply with Quote 
Links Not Showing Up

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('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',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('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',count($right))."<a href=\"http://lal.tulane.edu\">" .$row['subject']."</a><br>";
}
else if ($row['id'] !== "51")
{
echo str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',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('&nbsp;&nbsp;&nbsp;',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]
[Dec 4, 2006 10:30:33 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male admin
Advanced Member
Member's Avatar


Joined: Jun 14, 2003
Post Count: 2940
Status: Offline
Reply to this Post  Reply with Quote 
Re: Links Not Showing Up

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]
[Dec 4, 2006 11:13:49 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male Robbkore
Member




Joined: Sep 20, 2005
Post Count: 62
Status: Offline
Reply to this Post  Reply with Quote 
Re: Links Not Showing Up

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.
[Dec 4, 2006 12:21:07 PM] Show Printable Version of Post    View Member Profile    Send Private Message    Hidden to Guest [Link] Report threatening or abusive post: please login first  Go to top 
Male cboudy
Advanced Member
Member's Avatar


Joined: May 26, 2006
Post Count: 1757
Status: Offline
Reply to this Post  Reply with Quote 
Re: Links Not Showing Up

@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('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',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('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',count($right))."<a href=\"http://lal.tulane.edu\">" .$row['subject']."</a><br>";
}
else if ($row['id'] !== "51")
{
echo str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;',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('&nbsp;&nbsp;&nbsp;',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]
[Dec 4, 2006 1:27:37 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male admin
Advanced Member
Member's Avatar


Joined: Jun 14, 2003
Post Count: 2940
Status: Offline
Reply to this Post  Reply with Quote 
Re: Links Not Showing Up

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
[Dec 4, 2006 1:37:23 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male cboudy
Advanced Member
Member's Avatar


Joined: May 26, 2006
Post Count: 1757
Status: Offline
Reply to this Post  Reply with Quote 
Re: Links Not Showing Up

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.
[Dec 4, 2006 3:06:42 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread