Jump to content

Strange error on my site, can anyone help troubleshoot?


Darkmatter5

Recommended Posts

Here's the error.

"SELECT state_id, state, state_abbrev FROM thealien_byrnassoc.states ORDER BY state ASC

Incorrect information in file: './thealien_byrnassoc/states.frm'"

 

Here's the page that's reporting the error.

 

<?php
require('library/dbconfig.php');
require('library/byrndb_funcs.php');
$byrndb = new byrndb();
$page_title = "B.A.D.S. - Add new client record";
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $page_title; ?></title>

<link href="library/config.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="main">
  <div id="menu"><?php include('menu.php') ?></div>
  <div id="content-main">
    <div id="title"><?php include('title.php') ?></div>
    <div id="content">
    <form method="post">
    <table class="standard" width="770" border="0" align="left">
      <caption class="style1"><?php echo str_replace("B.A.D.S. - ","",strtoupper($page_title)); ?></caption>
      <tr>
        <td colspan="3" class="row_title">Fields marked <span class="required_text">red</span> are required.</td>
      </tr>
      <tr>
        <td width="257" colspan="2" class="column_headers" align="center">New data for database</td>
        <td width="513" class="column_headers" align="center">Description</td>
      </tr>
      <tr>
        <td width="113" class="row_title"><span class="required_text">First name</span>: </td>
        <td width="144" class="row_title"><input name="first_name" type="text" tabindex="1" /></td>
        <td rowspan="2" class="row_description">Enter clients first and last name. If the primary identifier of the client is a company name, also include a person as a contact for the company.</td>
      </tr>
      <tr>
        <td class="row_title"><span class="required_text">Last name</span>: </td>
        <td class="row_title"><input name="last_name" type="text" tabindex="2" /></td>
      </tr>
      <tr>
        <td class="row_title">Company name: </span></td>
        <td class="row_title"><input name="company_name" type="text" tabindex="3" /></td>
        <td class="row_description">Enter clients company name if the client is a company.</td>
      </tr>
      <tr>
        <td class="row_title">Contact Title: </span></td>
        <td class="row_title"><input name="contact_title" type="text" tabindex="4" /></td>
        <td class="row_description">Person job title in the company i.e. CEO, CIO, etc...</td>
      </tr>
      <tr>
        <td class="row_title">Address: </span></td>
        <td class="row_title"><input name="address" type="text" tabindex="5" /></td>
        <td class="row_description">Current mailing address.</td>
      </tr>
      <tr>
        <td class="row_title">City: </span></td>
        <td class="row_title"><input name="city" type="text" tabindex="6" /></td>
        <td class="row_description">Current city the client resides.</td>
      </tr>
      <tr>
        <td class="row_title">State: </span></td>
        <td class="row_title"><?php $byrndb->state_list(7,1); ?></td>
        <td class="row_description">Current state the client resides.</td>
      </tr>
      <tr>
        <td class="row_title">Zip code: </span></td>
        <td class="row_title"><input name="zip_code" type="text" tabindex="8" /></td>
        <td class="row_description">Current zip code the client resides.</td>
      </tr>
      <tr>
        <td class="row_title">Home phone: </span></td>
        <td class="row_title"><input name="home_phone" type="text" tabindex="9" /></td>
        <td class="row_description">Clients home phone number.</td>
      </tr>
      <tr>
        <td class="row_title">Work phone: </span></td>
        <td class="row_title"><input name="work_phone" type="text" tabindex="10" /></td>
        <td class="row_description">Clients work phone number.</td>
      </tr>
      <tr>
        <td class="row_title">Extension: </span></td>
        <td class="row_title"><input name="work_phone_extension" type="text" tabindex="11" /></td>
        <td class="row_description">Clients work phone extension number.</td>
      </tr>
      <tr>
        <td class="row_title">Fax phone: </span></td>
        <td class="row_title"><input name="fax_phone" type="text" tabindex="12" /></td>
        <td class="row_description">Clients fax phone number.</td>
      </tr>
      <tr>
        <td class="row_title">Email: </span></td>
        <td class="row_title"><input name="email" type="text" tabindex="13" /></td>
        <td class="row_description">Clients email address.</td>
      </tr>
    </table>
    </div>
    <div id="status" align="center">
    <table class="status" width="770" border="0" align="left">
    <caption class="style2">FORM STATUS</caption>
      <tr>
        <td width="113" align="center"><input name="addclient" type="submit" id="addclient" value="Submit new data" /></td>
        <td width="144" class="row_title" align="right">Function Status =></td>
        <td width="495" class="row_title" align="left">
            <?php
              if(isset($_POST['addclient'])) {
                    include 'library/dbconfig.php';
                  include 'library/opendb.php';
                  
                  if ($_POST[first_name]==NULL || $_POST[last_name]==NULL || $_POST[state]=="---Select---") {
                        echo "<div class='style26'>Required fields not entered!</div>";
                  } else { //handling textboxes
                        foreach (array('first_name','last_name','company_name','contact_title','address','city','zip_code','home_phone','work_phone','work_phone_extension','fax_phone','email') as $field) {
                            if ($_POST[$field]) {
                                $field_name[]=$field;
                              $field_value[]="'{$_POST[$field]}'";
                            }
                      }
                      //handling dropdown lists
                      $field_name[]='state_id';
                      $field_value[]=$_POST['state_id'];
                      //compile $fields and $values from $field_name and $field_value
                      $fields=join(", ", $field_name);
                      $values=join(", ", $field_value);
                      //insert data into table
                      $insertdata="INSERT INTO $dbname.clients ($fields) VALUES ($values)";
                      mysql_query($insertdata) or die(mysql_error() .": $insertdata");
                      echo $_POST[first_name]. " " .$_POST[last_name]. " ADDED to clients table...";
                  }
                  
                  include 'library/closedb.php';
              }
          ?>
        </td>
      </tr>    
    </table>
    </form>
    </div>
  </div>
</div>
</body>
</html>

 

Here's the state_list function that's trying to be called.

function state_list($tabindex,$default) {
            include 'library/dbconfig.php';
            include 'library/opendb.php';
            
            $query="SELECT state_id, state, state_abbrev
                    FROM $dbname.states
                    ORDER BY state ASC";
            $result=mysql_query($query) or die($query . '<br >'.mysql_error());
            echo "<select name='state_id' method='post' tabindex='$tabindex'>";
            echo "<option>---Select---</option>";
            while ($row=mysql_fetch_array($result)) {
                $r1=$row['state_id'];
                $r2=$row['state']. ", " .$row['state_abbrev'];
                if($default==$r1) {
                    echo "<option value='$r1' selected='selected'>$r2</option>";
                } elseif($default==NULL || $default!=$r1) {
                    echo "<option value='$r1'>$r2</option>";
                }
            }
            echo "</select>";
            
            include 'library/closedb.php';
        }

 

This similar error is happening on any page I have a drop-down list generated by a MySQL query.  Can anyone help me figure this out.  what does the error mean?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.