Afternoon,

I am currently the Webminister for http://www.calontir.org/ and am overseeing the transfer of our Web site from http://www.calontir.info to our new address. I am having issues with moving our Order of Precedence (OP) database.

The original OP database: http://calontir.info/herald/op/

The original pages work fine with the exception of one error on the op-page.php page.

The database on the new server: http://www.calontir.org/heraldry/op/

The option to view the entire list is the only page that works on the new server. (http://www.calontir.org/heraldry/op/op-all.php)

I believe the issues lie not in the mySQL database but on the PHP side of things. I am not a PHP guru by any means and have been learning as much as I can as I go. I can install scripts and modify templates but do not have much experience beyond that.

I do know that the original code for this script was written around 10 years ago.

Calontir.info is running PHP 4.4.9 and calontir.org is running PHP Version 5.2.17.

op-page.php
Errors -
Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 16 in /home/content/21/7394721/html/heraldry/op/op-page.php on line 58

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 208 in /home/content/21/7394721/html/heraldry/op/op-page.php on line 98

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/content/21/7394721/html/heraldry/op/op-page.php on line 140

<?php

$file = fopen("op-template.html", "r");

if (!$file) 
{
  echo "<P>Template not available.</P>\n";
  exit;
}
else
{
  while (!feof($file) ) 
  {
    $line = fgets($file, 1024);
    if ( strstr($line, "insert content here") )
    {
      break;
    }
    else
    {
      echo "$line";
    }
  }
}

include("*link to database login info*");
dbLogin();

$qryStr = "SELECT AwardDate FROM Awards ORDER BY AwardDate DESC";
$awardRS = mysql_query($qryStr);
$numAward = mysql_num_rows($awardRS);

$lastDate = mysql_result($awardRS,0,"AwardDate");
echo "<H2>Calontir Roll of Awards<SPAN STYLE=\"font-size: 12pt; font-weight: bold;\"> - Current as of $lastDate</SPAN></H2>\n";

$countRS = mysql_query("SELECT Count(PopInd) as recCount FROM Populace");
$numCount = mysql_num_rows($countRS);
$popCount = mysql_result($countRS,0,"recCount");
$pages = 100;
$ppp = floor($popCount/$pages) + 1;
$pages = ceil($popCount/$ppp);

print("<TABLE CELLPADDING=2 CELLSPACING=1 BORDER=1 bordercolordark=#9933CC bordercolorlight=#CC66FF>\n");
print("  <TR>\n");
print("    <TD VALIGN=top>\n");

print("      <TABLE CELLPADDING=4 CELLSPACING=0>\n");
print("        <TR><TD><A HREF=\"index.html\">OP Home</A></TD></TR>\n");
print("        <TR><TD COLSPAN=2><HR></TD></TR>\n");
print("        <TR><TD>Page</TD></TR>\n");
for ($i = 1; $i <= $pages; $i++)
{
  $start = ( $i - 1 ) * $ppp + 1;
  $end = $start + $ppp - 1;

  $popRS = mysql_query("SELECT Name FROM Populace WHERE PopInd =' $start ' ORDER BY Name");
  $numPop = mysql_num_rows($popRS);
  $first =  mysql_result($popRS,0,"Name");
  echo "Query: " . $popRS;
  $first = substr($first, 0, 3);

  $popRS = mysql_query("SELECT Name FROM Populace WHERE PopInd =' $end ' ORDER BY Name");
  $numPop = mysql_num_rows($popRS);
  if ( $numPop > 0 )
  {
    $last = mysql_result($popRS,0,"Name");
  }
  else
  {
    $end = $popCount - 1;
    $popRS = mysql_query("SELECT Name FROM Populace WHERE PopInd =' $end '");
    $last = mysql_result($popRS,0,"Name");
  }
  $last = substr($last, 0, 3);

  if ( $i == $page )
  {
    print ("        <TR><TD STYLE=\"font-weight: bold; color: goldenrod;\">$i  $first - $last</TD></TR>\n");
  }
  else
  {
    print ("        <TR><TD><A HREF=\"http://www.calontir.org/heraldry/op/op-page.php?page=$i\">$i  $first - $last</A></TD></TR>\n");
  }
}
print("        <TR><TD><A HREF=\"index.html\">OP Home</A></TD></TR>\n");
print("      </TABLE>\n");

print("    </TD>\n");
print("    <TD VALIGN=top>\n");

print("      <TABLE BORDER=0>\n");
$start = ( $page - 1 ) * $ppp + 1;
$end = $start + $ppp - 1;

$popRS = mysql_query("SELECT Name FROM Populace WHERE PopInd =' $start ' ORDER BY Name");
$numPop = mysql_num_rows($popRS);
  echo "Query: " . $popRS;
$first =  mysql_result($popRS,0,"Name");

$popRS = mysql_query("SELECT Name FROM Populace WHERE PopInd =' $end ' ORDER BY Name");
$numPop = mysql_num_rows($popRS);
if ( $numPop > 0 )
{
  $last = mysql_result($popRS,0,"Name");
}
else
{
  $end = $popCount - 1;
  $popRS = mysql_query("SELECT Name FROM Populace WHERE PopInd =' $end '");
  $last = mysql_result($popRS,0,"Name");
}
#print("        <TR><TD COLSPAN=4><H2>Results for Page $page <SPAN STYLE=\"font-weight: normal; font-size: 12pt;\">($start-$first to $end-$last)</SPAN)</H2></TD></TR>\n");
print("        <TR><TD COLSPAN=4><H2>Results for Page $page <SPAN STYLE=\"font-weight: normal; font-size: 12pt;\">($first to $last)</SPAN)</H2></TD></TR>\n");
$p = $page - 1;
if ( $p < 1 )
{
  $p = 1;
}
$n = $page + 1;
if ( $n > $pages )
{
  $n = $pages;
}

print("        <TR><TD><A HREF=\"http://www.calontir.org/heraldry/op/op-page.php?page=1\">First</A></TD>\n");
print("            <TD><A HREF=\"http://www.calontir.org/heraldry/op/op-page.php?page=$p\">Previous</A></TD>\n");
print("            <TD><A HREF=\"http://www.calontir.org/heraldry/op/op-page.php?page=$n\">Next</A></TD>\n");
print("            <TD><A HREF=\"http://www.calontir.org/heraldry/op/op-page.php?page=$pages\">Last</A></TD></TR>\n");

echo "        <TR>\n";
echo "          <TD COLSPAN=4>\n";
echo "            <TABLE CELLPADDING=2 CELLSPACING=1 BORDER=1 bordercolordark=#9933CC bordercolorlight=#CC66FF>\n";

$kListRS = mysql_query("SELECT * FROM Kingdoms ORDER BY KingdomInd");
$numKList = mysql_num_rows($kListRS);

$start = ( $page - 1 ) * $ppp;
$popRS = mysql_query("SELECT * FROM Populace ORDER BY Name LIMIT $start, $ppp");
  echo "Query: " . $popRS;
$numPop = mysql_num_rows($popRS);
$i = 0;

while($i < $numPop)
{
  $ind = mysql_result($popRS,$i,"PopInd");
  $name =  mysql_result($popRS,$i,"Name");
  $altNames = mysql_result($popRS,$i,"AltNames");
  $PopInd = mysql_result($popRS,$i,"PopInd");

  echo "              <TR>\n";
  echo "                <TD WIDTH=600>\n";
  if ( $altNames == "" )
  {
#    echo "                  <SPAN STYLE=\"font-weight: bold;\">$name</SPAN> ($ind)\n";
    echo "                  <SPAN STYLE=\"font-weight: bold;\">$name</SPAN>\n";
  }
  else
  {
#    echo "                  <SPAN STYLE=\"font-weight: bold;\">$name</SPAN> ($ind)<BR>    $altNames\n";
    echo "                  <SPAN STYLE=\"font-weight: bold;\">$name</SPAN><BR>    $altNames\n";
  }
  echo "                  <HR>\n";

  $awardRS = mysql_query("SELECT * FROM Awards WHERE PopInd =' $PopInd ' ORDER BY AwardDate");
  $numAward = mysql_num_rows($awardRS);

  $j = 0;

  echo "                  <TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>";
  while($j < $numAward)
  {
    $ac = mysql_result($awardRS,$j,"awardCode");
    $awardDate = mysql_result($awardRS,$j,"awardDate");
    $aListRS = mysql_query("SELECT * FROM AwardList WHERE AwardInd = ' $ac '");
    $numAList = mysql_num_rows($aListRS);
    $awardName = mysql_result($aListRS,0,"Name");
    $kc = mysql_result($awardRS,$j,"KingdomCode");
    if ( $kc != 0 )
    {
      $kc = $kc - 1;
      $Kingdom = mysql_result($kListRS,$kc,"Name");
      echo "                    <TR><TD>$awardName</TD><TD> </TD><TD>$awardDate</TD><TD> </TD><TD>$Kingdom</TD></TR>\n";
    }
    else
    {
      echo "                    <TR><TD>$awardName</TD><TD> </TD><TD>$awardDate</TD></TR>\n";
    }
    $j++;
  }
  echo "                  </TABLE>\n";
  echo "                </TD>\n";
  echo "              </TR>\n";
  echo "              <TR><TD HEIGHT=4 BGCOLOR=gold></TD></TR>\n";
  $i++;
}

echo "            </TABLE>\n";

print("          </TD>\n");
print("        </TR>\n");
print("        <TR><TD><A HREF=\"http://www.calontir.org/heraldry/op/op-page.php?page=1\">First</A></TD>\n");
print("            <TD><A HREF=\"http://www.calontir.org/heraldry/op/op-page.php?page=$p\">Previous</A></TD>\n");
print("            <TD><A HREF=\"http://www.calontir.org/heraldry/op/op-page.php?page=$n\">Next</A></TD>\n");
print("            <TD><A HREF=\"http://www.calontir.org/heraldry/op/op-page.php?page=$pages\">Last</A></TD></TR>\n");
print("        <TR><TD ALIGN=CENTER COLSPAN=4 BGCOLOR=GOLD><A HREF=\"submitupdate.html\">OP Correction Submission Form</A></TD></TR>\n");

print("      </TABLE>\n");

print("    </TD>\n");
print("  </TR>\n");
print("</TABLE>\n");

while (!feof($file) )
{
  $line = fgets($file, 1024);
  echo "$line";
}

fclose($file);
?>

op-alpha.php

<?php

$file = fopen("op-template.html", "r");

if (!$file) 
{
  echo "<P>Template not available.</P>\n";
  exit;
}
else
{
  while (!feof($file) ) 
  {
    $line = fgets($file, 1024);
    if ( strstr($line, "insert content here") )
    {
      break;
    }
    else
    {
      echo "$line";
    }
  }
}

include("*link to database login info*");
dbLogin();

$awardRS = mysql_query("SELECT AwardDate FROM Awards ORDER BY AwardDate DESC");
$numAward = mysql_num_rows($awardRS);

$lastDate = mysql_result($awardRS,0,"AwardDate");
echo "<H2>Calontir Roll of Awards<SPAN STYLE=\"font-size: 12pt; font-weight: bold;\"> - Current as of $lastDate</SPAN></H2>\n";

$countRS = mysql_query("SELECT Count(PopInd) as recCount FROM Populace");
$numCount = mysql_num_rows($countRS);
$popCount = mysql_result($countRS,0,"recCount");
$pages = 26;

print("<TABLE iCELLPADDING=2 CELLSPACING=1 BORDER=1 bordercolordark=#9933CC bordercolorlight=#CC66FF>\n");
print("<TR>\n");
print("<TD VALIGN=top>\n");

print("<TABLE CELLPADDING=8 CELLSPACING=0>\n");
print("<TR><TD><A HREF=\"index.html\">OP Home</A></TD></TR>\n");
print("<TR><TD COLSPAN=2><HR></TD></TR>\n");
print("<TR><TD>Page</TD></TR>\n");
for ($i = 1; $i <= $pages; $i++)
{
  $letter = chr( $i + 64);
  if ( $i == $page )
  {
    print ("<TR><TD STYLE=\"font-weight: bold; color: goldenrod;\">$letter</TD></TR>\n");
  }
  else
  {
    print ("<TR><TD><A HREF=\"http://www.calontir.org/heraldry/op/op-alpha.php?page=$i\">$letter</A></TD></TR>\n");
  }
}
print("</TABLE>\n");

print("</TD>\n");
print("<TD VALIGN=top>\n");

print("<TABLE>\n");
if ( $page >= 1 && $page <= 26 )
{
  $letter = chr($page + 64);
print("<TR><TD COLSPAN=4>Results for the letter <B>$letter</B></TD></TR>\n");
}
else
{
  $letter = " ";
  print("<TR><TD COLSPAN=4>Please Select a letter</TD></TR>\n");
}
$p = $page - 1;
if ( $p < 0 )
{
  $p = 0;
}
$n = $page + 1;
if ( $n > 26 )
{
  $n = 26;
}

print("<TR><TD><A HREF=\"http://www.calontir.org/heraldry/op/op-alpha.php?page=1\">First</A></TD>\n");
print("<TD><A HREF=\"http://www.calontir.org/heraldry/op/op-alpha.php?page=$p\">Previous</A></TD>\n");
print("<TD><A HREF=\"http://www.calontir.org/heraldry/op/op-alpha.php?page=$n\">Next</A></TD>\n");
print("<TD><A HREF=\"http://www.calontir.org/heraldry/op/op-alpha.php?page=$pages\">Last</A></TD></TR>\n");


echo "        <TR>\n";
echo "          <TD COLSPAN=4>\n";
echo "            <TABLE CELLPADDING=2 CELLSPACING=1 BORDER=1 bordercolordark=#9933CC bordercolorlight=#CC66FF>\n";

$kListRS = mysql_query("SELECT * FROM Kingdoms ORDER BY KingdomInd");
$numKList = mysql_num_rows($kListRS);

$start = ( $page - 1 ) * $ppp;
$popRS = mysql_query("SELECT * FROM Populace WHERE Name LIKE '$letter%' ORDER BY Name");
$numPop = mysql_num_rows($popRS);
$i = 0;

while($i < $numPop)
{
  $ind = mysql_result($popRS,$i,"PopInd");
  $name =  mysql_result($popRS,$i,"Name");
  $altNames = mysql_result($popRS,$i,"AltNames");
  $PopInd = mysql_result($popRS,$i,"PopInd");

  echo "              <TR>\n";
  echo "                <TD WIDTH=600>\n";
  if ( $altNames == "" )
  {
#    echo "                  <SPAN STYLE=\"font-weight: bold;\">$name</SPAN> ($ind)\n";
    echo "                  <SPAN STYLE=\"font-weight: bold;\">$name</SPAN>\n";
  }
  else
  {
#    echo "                  <SPAN STYLE=\"font-weight: bold;\">$name</SPAN> ($ind)<BR>    $altNames\n";
    echo "                  <SPAN STYLE=\"font-weight: bold;\">$name</SPAN><BR>    $altNames\n";
  }
  echo "                  <HR>\n";

  $awardRS = mysql_query("SELECT * FROM Awards WHERE PopInd =' $PopInd ' ORDER BY AwardDate");
  $numAward = mysql_num_rows($awardRS);

  $j = 0;

  echo "                  <TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>";

  while($j < $numAward)
  {
    $ac = mysql_result($awardRS,$j,"awardCode");
    $awardDate = mysql_result($awardRS,$j,"awardDate");
    $aListRS = mysql_query("SELECT * FROM AwardList WHERE AwardInd = ' $ac '");
    $numAList = mysql_num_rows($aListRS);
    $awardName = mysql_result($aListRS,0,"Name");
    $kc = mysql_result($awardRS,$j,"KingdomCode");
    if ( $kc != 0 )
    {
      $kc = $kc - 1;
      $Kingdom = mysql_result($kListRS,$kc,"Name");
      echo "                    <TR><TD>$awardName</TD><TD> </TD><TD>$awardDate</TD><TD> </TD><TD>$Kingdom</TD></TR>\n";
    }
    else
    {
      echo "                    <TR><TD>$awardName</TD><TD> </TD><TD>$awardDate</TD></TR>\n";
    }
    $j++;
  }
  echo "                  </TABLE>\n";
  echo "                </TD>\n";
  echo "              </TR>\n";
  echo "              <TR><TD HEIGHT=4 BGCOLOR=gold></TD></TR>\n";
  $i++;
}

echo "            </TABLE>\n";

print("          </TD>\n");
print("        </TR>\n");

print("<TR><TD><A HREF=\"http://www.calontir.org/heraldry/op/op-alpha.php?page=1\">First</A></TD>\n");
print("<TD><A HREF=\"http://www.calontir.org/heraldry/op/op-alpha.php?page=$p\">Previous</A></TD>\n");
print("<TD><A HREF=\"http://www.calontir.org/heraldry/op/op-alpha.php?page=$n\">Next</A></TD>\n");
print("<TD><A HREF=\"http://www.calontir.org/heraldry/op/op-alpha.php?page=$pages\">Last</A></TD></TR>\n");
print("<TR><TD ALIGN=CENTER COLSPAN=4 BGCOLOR=GOLD><A HREF=\"submitupdate.html\">OP Correction Submission Form</A></TD></TR>\n");

print("</TABLE>\n");

print("</TD>\n");
print("</TR>\n");
print("</TABLE>\n");

while (!feof($file) )
{
  $line = fgets($file, 1024);
  echo "$line";
}

fclose($file);
?>

op-name.php

<?php

if ( $submit == "clear" )
{
  $search = "";
  $matchCase = "";
  $startName = "";
  $passName = "";
}

$file = fopen("op-template.html", "r");
if (!$file) 
{
  echo "<P>Template not available.</P>\n";
  exit;
}
else
{
  while (!feof($file) ) 
  {
    $line = fgets($file, 1024);
    if ( strstr($line, "insert content here") )
    {
      break;
    }
    else
    {
      if ($line == "</HEAD>\n")
      {
        print ("<SCRIPT Language=\"Javascript1.2\">\n");
        print ("<!--\n");
        print ("function mysubmit(form) {\n");
#        print ("           document.myform.submit();\n");
#        print ("           document.myform.search.value = document.myform.passName.value;\n");
#        print ("           alert(\"Radio Button Clicked \" + document.myform.order.value);\n");
        print ("         }\n");
        print ("-->\n");
        print ("</SCRIPT>\n");
      }
      echo "$line";
    }
  }
}

$search = ereg_replace("_", " ", $search);
$display = ereg_replace("\\^", "", $search);
$display = ereg_replace("\\$", "", $display);

include("*link to database login info*");
dbLogin();

$awardRS = mysql_query("SELECT AwardDate FROM Awards ORDER BY AwardDate DESC");
$numAward = mysql_num_rows($awardRS);

$lastDate = mysql_result($awardRS,0,"AwardDate");
echo "<H2>Calontir Roll of Awards<SPAN STYLE=\"font-size: 12pt; font-weight: bold;\"> - Current as of $lastDate</SPAN></H2>\n";

print("<TABLE CELLPADDING=2 CELLSPACING=1 BORDER=1 bordercolordark=\"#9933CC\" bordercolorlight=\"#CC66FF\">\n");
print("  <TR>\n");
print("    <TD VALIGN=top>\n");

print("      <FORM NAME=\"myform\">\n");

print("        <TABLE CELLPADDING=2 CELLSPACING=1 BORDER=0>\n");
print("          <TR><TD><A HREF=\"index.html\">OP Home</A></TD></TR>\n");
print("          <TR><TD COLSPAN=2><HR></TD></TR>\n");
print("          <TR>\n");
print("            <TD COLSPAN=2>\n");
print("              Specify search text:\n");
print("            </TD>\n");
print("          </TR>\n");
print("          <TR>\n");
print("            <TD COLSPAN=2>\n");
print("              <INPUT TYPE=text SIZE=40 NAME=search VALUE='$display'>\n");
print("            </TD>\n");
print("          </TR>\n");
print("          <TR>\n");
print("            <TD>\n");
if ( $matchCase == "on" )
{
  print("              Match Case <INPUT TYPE='checkbox' CHECKED NAME='matchCase'>\n");
}
else
{
  print("              Match Case <INPUT TYPE='checkbox' NAME='matchCase'>\n");
}
print("            </TD>\n");
print("            <TD>\n");
if ( $startName == "on" )
{
  print("              Start of Name <INPUT TYPE='checkbox' CHECKED NAME='startName'>\n");
}
else
{
  print("              Start of Name <INPUT TYPE='checkbox' NAME='startName'>\n");
}
print("            </TD>\n");
print("          </TR>\n");
print("          <TR>\n");
print("            <TD>\n");
print("              <INPUT TYPE='submit' VALUE='search' NAME='submit'>\n");
print("            </TD>\n");
print("            <TD>\n");
print("              <INPUT TYPE='submit' VALUE='clear' NAME='submit'>\n");
print("            </TD>\n");
print("          </TR>\n");
print("        </TABLE>\n");

print("    </TD>\n");
print("    <TD VALIGN=top>\n");
print("      <TABLE>\n");

if ( $passName != "")
{
  $passName = ereg_replace("_", " ", $passName);

  $search = $passName;
#  document.myform.search.value = $passName;
}

if ( $search == "" )
{
  print("        <TR><TD COLSPAN=2>Please specify search text.</TD></TR>\n");
}
else
{
  if ($order == 2)
  {
    print("        <TR><TD COLSPAN=2>Search results for <SPAN STYLE=\"font-weight: bold;\">$display</SPAN>.</TD><TD>Order By:&nbsp;&nbsp;Precedence<INPUT TYPE=\"radio\" NAME=\"order\" VALUE=\"1\" onClick=\"mysubmit(this.form);\"> Award Date<INPUT CHECKED TYPE=\"radio\" NAME=\"order\" VALUE=\"2\"  onClick=\"mysubmit(this.form);\"></TD><TD><INPUT TYPE='Submit' VALUE='Go!' NAME='submit'></TD></TR>\n");    
  }
  else
  {
    print("         <TR><TD COLSPAN=2>Search results for <SPAN STYLE=\"font-weight: bold;\">$display</SPAN>.</TD><TD>Order By:&nbsp;&nbsp;Precedence<INPUT CHECKED TYPE=\"radio\" NAME=\"order\" VALUE=\"1\" onClick=\"mysubmit(this.form);\"> Award Date<INPUT TYPE=\"radio\" NAME=\"order\" VALUE=\"2\" onClick=\"mysubmit(this.form);\"></TD><TD><INPUT TYPE='Submit' VALUE='Go!' NAME='submit'></TD></TR>\n");
  }
  echo "        <TR>\n";
  echo "          <TD COLSPAN=4>\n";
  echo "            <TABLE CELLPADDING=2 CELLSPACING=1 BORDER=1 bordercolordark=\"#9933CC\" bordercolorlight=\"#CC66FF\">\n";

  $kListRS = mysql_query("SELECT * FROM Kingdoms ORDER BY KingdomInd");
  $numKList = mysql_num_rows($kListRS);

  if ( $matchCase == "on" )
  {
    if ( $startName == "on" )
    {
      $whereClause = "Name REGEXP BINARY \"^$search\"";
    }
    else
    {
      $whereClause = "Name REGEXP BINARY \"$search\"";
    }
  }
  else
  {
    if ( $startName == "on" )
    {
      $whereClause = "Name REGEXP \"^$search\"";
    }
    else
    {
      $whereClause = "Name REGEXP \"$search\"";
    }
  }

  $countRS = mysql_query("SELECT count(PopInd) as recCount FROM Populace WHERE $whereClause ORDER BY Name");
  $numPop = mysql_num_rows($countRS);
  $recCount = mysql_result($countRS,0,"recCount");

  if ( $recCount == 0 )
  {
    echo "              <TR><TD>No results returned, please broaden your search.</TD></TR>\n";
  }
  else
  {
    $popRS = mysql_query("SELECT * FROM Populace WHERE $whereClause ORDER BY Name");
    $numPop = mysql_num_rows($popRS);
    $i = 0;

    while($i < $numPop)
    {
      $ind = mysql_result($popRS,$i,"PopInd");
      $popName =  mysql_result($popRS,$i,"Name");
      $altNames = mysql_result($popRS,$i,"AltNames");
      $PopInd = mysql_result($popRS,$i,"PopInd");

      echo "              <TR>\n";
      echo "                <TD WIDTH=600>\n";
      $linkName = ereg_replace(" ", "_", $popName);
      if ( $altNames == "" )
      {
#        echo "                  <SPAN STYLE=\"font-weight: bold;\">$popName</SPAN> ($ind)\n";
        echo "                  <SPAN STYLE=\"font-weight: bold;\"><A HREF=\"op-name.php?search=^$linkName\$\">$popName</A></SPAN>\n";
      }
      else
      {
#        echo "                  <SPAN STYLE=\"font-weight: bold;\">$popName</SPAN> ($ind)<BR>&nbsp;&nbsp;&nbsp;&nbsp;$altNames\n";
        echo "                  <SPAN STYLE=\"font-weight: bold;\"><A HREF=\"op-name.php?search=^$linkName\$\">$popName</A></SPAN><BR>&nbsp;&nbsp;&nbsp;&nbsp;$altNames\n";
      }

      if ( $recCount == 1 )
      {
        echo "                  <HR>\n";
        if ( $order == 2 )
        {
          $awardRS = mysql_query("SELECT Awards.PopInd, Awards.AwardCode, Awards.AwardDate, Awards.KingdomCode, AwardList.Precedence FROM Awards, AwardList WHERE Awards.PopInd =' $PopInd ' and AwardList.AwardInd = Awards.AwardCode ORDER BY Awards.AwardDate, AwardList.Precedence");          
        }
        else
        {  
          $awardRS = mysql_query("SELECT Awards.PopInd, Awards.AwardCode, Awards.AwardDate, Awards.KingdomCode, AwardList.Precedence FROM Awards, AwardList WHERE Awards.PopInd =' $PopInd ' and AwardList.AwardInd = Awards.AwardCode ORDER BY AwardList.Precedence, Awards.AwardDate"); 
        }
        $numAward = mysql_num_rows($awardRS);

        $j = 0;

        echo "                  <TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>";

        while($j < $numAward)
        {
          $ac = mysql_result($awardRS,$j,"awardCode");
          $awardDate = mysql_result($awardRS,$j,"awardDate");
          $aListRS = mysql_query("SELECT * FROM AwardList WHERE AwardInd = ' $ac '");
          $numAList = mysql_num_rows($aListRS);
          $awardName = mysql_result($aListRS,0,"Name");
          $kc = mysql_result($awardRS,$j,"KingdomCode");
          if ( $kc != 10 )
          {
            $kc = $kc - 1;
            $Kingdom = mysql_result($kListRS,$kc,"Name");
            echo "                    <TR><TD>$awardName</TD><TD>&nbsp;</TD><TD>$awardDate</TD><TD>&nbsp;</TD><TD>$Kingdom</TD></TR>\n";
          }
          else
          {
            echo "                    <TR><TD>$awardName</TD><TD>&nbsp;</TD><TD>$awardDate</TD></TR>\n";
          }
          $j++;
        }
        echo "                   </TABLE>\n";
      }
      echo "                </TD>\n";
      echo "              </TR>\n";
      $i++;
    }
  }
  print("            </TABLE>\n");
  print("          </TD>\n");
  print("        </TR>\n");
}
echo "      </TABLE>\n";
print("      </FORM>\n");

print("    </TD>\n");
print("  </TR>\n");
print("</TABLE>\n");

# print("</TD>\n");
# print("</TR>\n");
# print("</TABLE>\n");

while (!feof($file) )
{
  $line = fgets($file, 1024);
  echo "$line";
}

fclose($file);
?>

op-awardbydate.php

<?php

if ( $submit == "clear" )
{
  $search = "";
  $matchCase = "";
  $startName = "";
  $passName = "";
}

$file = fopen("op-template.html", "r");
if (!$file) 
{
  echo "<P>Template not available.</P>\n";
  exit;
}
else
{
  while (!feof($file) ) 
  {
    $line = fgets($file, 1024);
    if ( strstr($line, "insert content here") )
    {
      break;
    }
    else
    {
      echo "$line";
    }
  }
}

include("*link to database login info*");
dbLogin();

$awardRS = mysql_query("SELECT AwardDate FROM Awards ORDER BY AwardDate DESC");
$numAward = mysql_num_rows($awardRS);

$lastDate = mysql_result($awardRS,0,"AwardDate");
echo "<H2>Calontir Roll of Awards<SPAN STYLE=\"font-size: 12pt; font-weight: bold;\"> - Current as of $lastDate</SPAN></H2>\n";

print("<TABLE CELLPADDING=2 CELLSPACING=1 BORDER=1 bordercolordark=#9933CC bordercolorlight=#CC66FF>\n");
print("<TR>\n");
print("<TD VALIGN=top>\n");

print("<FORM METHOD=post ACTION='op-awardbydate.php'>\n");

print("<TABLE CELLPADDING=2 CELLSPACING=1 BORDER=0>\n");
print("<TR><TD><A HREF=\"index.html\">OP Home</A></TD></TR>\n");
print("<TR><TD COLSPAN=2><HR></TD></TR>\n");
print("<TR>\n");
print("<TD COLSPAN=2>\n");
print("Specify award:\n");
print("</TD>\n");
print("</TR>\n");
print("<TR>\n");
print("<TD COLSPAN=2>\n");
print("<SELECT NAME=award>\n");


$aListRS = mysql_query("SELECT AwardInd, Name FROM AwardList ORDER BY AwardInd");
$numAward = mysql_num_rows($aListRS);
$awardName = mysql_result($aListRS,0,"Name");

$i = 0;


if ( $award == "" )
{
  $award = -30;
}

while($i < $numAward)
{
  print("current = $i, looking for $award<BR>\n");
  $awardCode =  mysql_result($aListRS,$i,"awardInd");
  $awardName =  mysql_result($aListRS,$i,"Name");
  if ( $awardCode <= 100 )
  { 
    if ( $i == abs($award)  - 1 )
    {
      print("<OPTION SELECTED VALUE=$awardCode>$awardName</OPTION>\n");
    }
    else
    {
      print("<OPTION VALUE=$awardCode>$awardName</OPTION>\n");
    }
  }
  else
  {
    if ( $award == 100 )
    {
      print("<OPTION SELECTED VALUE=100>All Others</OPTION>\n");
    }
    else
    {
      print("<OPTION VALUE=100>All Others</OPTION>\n");
    }
    break;
  }
  $i++;
}
print("</SELECT>\n");
print("</TD>\n");
print("</TR>\n");
print("<TR>\n");
print("<TD>\n");
print("<INPUT TYPE='submit' VALUE='select' NAME='submit'>\n");
print("</TD>\n");
print("<TD>\n");
print("<INPUT TYPE='submit' VALUE='clear' NAME='submit'>\n");
print("</TD>\n");
print("</TR>\n");
print("</TABLE>\n");
print("</FORM>\n");

print("</TD>\n");
print("<TD VALIGN=top>\n");

print("<TABLE>\n");

if ( $award == "" || $award == -30 )
{
  print("<TR><TD COLSPAN=2>Please select an award or order.</TD></TR>\n");
}
else
{
  if ( $award != 100 )
  {
    $anameRS = mysql_query("SELECT Name FROM AwardList WHERE AwardInd ='$award'");
    $numAward = mysql_num_rows($anameRS);
    $awardName = mysql_result($anameRS,0,"Name");
    $countRS = mysql_query("SELECT count(PopInd) as recCount FROM Awards WHERE AwardCode ='$award'");
    $awardRS = mysql_query("SELECT * FROM Awards WHERE AwardCode ='$award' ORDER BY AwardDate");
  }
  else
  {
    $awardName = "All non Calontir Awards";
    $countRS = mysql_query("SELECT count(PopInd) as recCount FROM Awards WHERE AwardCode >='$award'");
    $kListRS = mysql_query("SELECT * FROM Kingdoms ORDER BY KingdomInd");
    $numKList = mysql_num_rows($kListRS);
    $awardRS = mysql_query("SELECT * FROM Awards WHERE AwardCode >='$award' ORDER BY AwardCode, AwardDate");
  }

  $numCount = mysql_num_rows($countRS);
  $aCount = mysql_result($countRS,0,"recCount");

  print("<TR><TD COLSPAN=2>Roll of the <SPAN STYLE=\"font-weight: bold;\">$awardName</SPAN>, $aCount bestowed.</TD></TR>\n");
  echo "<TR>\n";
  echo "<TD COLSPAN=4>\n";
  echo "<TABLE CELLPADDING=2 CELLSPACING=1 BORDER=1 bordercolordark=#9933CC bordercolorlight=#CC66FF>\n";

  $numAward = mysql_num_rows($awardRS);

  $i = 0;

  while($i < $numAward)
  {
    echo "<TR>\n";
    echo "<TD>\n";
    $ac =  mysql_result($awardRS,$i,"AwardCode");
    $PopInd =  mysql_result($awardRS,$i,"PopInd");
    $awardDate =  mysql_result($awardRS,$i,"awardDate");
    echo "<TABLE WIDTH=560 CELLPADDING=2 CELLSPACING=0 BORDER=0>\n";
    echo "<TR>\n";
    $ind = $i + 1;
    if ( $award == 100 )
    {
      $kc =  mysql_result($awardRS,$i,"kingdomCode");
      $kc = $kc - 1;
      $anameRS = mysql_query("SELECT Name FROM AwardList WHERE AwardInd = '$ac'");
      $numAName = mysql_num_rows($anameRS);
      $awardName = mysql_result($anameRS,0,"Name");
      echo "<TD WIDTH=120><SPAN STYLE=\"font-weight: normal;\">$awardName</SPAN></TD>\n";
#      echo "<TD> </TD>\n";
      $Kingdom = mysql_result($kListRS,$kc,"Name");
      echo "<TD WIDTH=100><SPAN STYLE=\"font-weight: normal;\">$Kingdom</SPAN></TD>\n";
      //echo "<TD WIDTH=40><SPAN STYLE=\"font-weight: normal;\">$ind</SPAN></TD>\n";
    }
    echo "<TD WIDTH=90>$awardDate</TD>\n";
#    echo "<TD> </TD>\n";

    $popRS = mysql_query("SELECT Name FROM Populace WHERE PopInd ='$PopInd'");
    $numPop = mysql_num_rows($popRS);
    $popName =  mysql_result($popRS,0,"Name");

    echo "<TD WIDTH=250><SPAN STYLE=\"font-weight: bold;\"><A HREF=\"op-name.php?passName=$popName\">$popName</SPAN>\n";
    echo "</TR>\n";
    echo "</TABLE>\n";
    echo "</TD>\n";
    echo "</TR>\n";
    echo "<TR><TD HEIGHT=4 BGCOLOR=gold></TD></TR>\n";
    $i++;
  }


  echo "</TABLE>\n";
}

print("</TD>\n");
print("</TR>\n");
print("<TR><TD ALIGN=CENTER COLSPAN=4 BGCOLOR=GOLD><A HREF=\"submitupdate.html\">OP Correction Submission Form</A></TD></TR>\n");
print("</TABLE>\n");

print("</TD>\n");
print("</TR>\n");
print("</TABLE>\n");

while (!feof($file) )
{
  $line = fgets($file, 1024);
  echo "$line";
}

fclose($file);
?>

Thank you so much for your help, I really appreciate it!

Namas te,
Jennifer Langley

Recommended Answers

All 11 Replies

Member Avatar for iamthwee

That's a lot of code to wade through, doubtful anyone has the time...


Can you pinpoint/be more specific.

See the sticky thread on the top on this forum, on how to detect mysql errors (the warning is different, yet the problem is the same). The warnings you see are triggered, because some of your queries return errors, or no results. Add error checking to avoid this problem.

Thanks!

Adding error checking provided the following new information for the op-page.php:

"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-40, 40' at line 1Query:"

I believe the related code is:

$start = ( $page - 1 ) * $ppp;
$popRS = mysql_query("SELECT * FROM Populace ORDER BY Name LIMIT $start, $ppp");
if(!$popRS) {
  echo mysql_error();
}
  echo "Query: " . $popRS;
$numPop = mysql_num_rows($popRS);
$i = 0;

Namas te,
Jennifer Langley

the start of a LIMIT clause must be zero or higher, NOT negative.

Probably $page starts with one?
Try to echo "SELECT * FROM Populace ORDER BY Name LIMIT $start, $ppp" first, and run that in phpmyadmin or something similar.

Okay,

I think $page starts with one too.

twiss, I ran the echo through phpmyadmin and here is what it returned:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'echo &quot;SELECT * FROM Populace ORDER BY Name LIMIT $start, $ppp&quot;' at line 1

Namas te,
- J

No, that's not what I mean. Place that line after the first of those 8 lines you posted above. See what it echoes if you run that script. Post that here, copy it to phpmyadmin, and see what that says.

twiss,

Sorry, misunderstood you!

Here is what it echoes when I run the script: SELECT * FROM Populace ORDER BY Name LIMIT -39, 40 And this is what myphpadmin says:

MySQL said:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-39, 40' at line 1

Namas te,
-J

What you're doing with $page is wrong. IMO you're changing its value too often, why is this? What you could also try is put echo 'line '.__LINE__.': $page is now '.$page.'<br>'; after every line in which you change $page, and inspect that.

twiss,

Thanks, but I didn't write the code. It was written 10 years ago by a predecessor of my office. I'm just the lucky monkey that gets to play with/fix it. :)

I ran the new echo script and each line that echoed ends in $page is now So now I'm thinking maybe $page has no value.

Thank you so much for your patience and help. I really, really appreciate it!

Namas te,
- J

Hmmmm. Well, I find all that code a bit too long to analyze it all, but perhaps adding $page = $page ? $page : 1; before that line in which you set $start helps?

If that doesn't work or if it works only for the first page (not the second), you'll have to dig through all of that code to find out what it does and why it doesn't do it correctly - or rewrite the whole thing. But other programmers always tell me I rewrite code too often or too soon, so don't take my word for it :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.