Jump to content

I can't find the error, need another set of eyees to see it


jim.davidson

Recommended Posts

I'm using php, dreamweaver 8, and mySQL 4.1.21

 

I have two dropdown menus on my update form, one for states and one for countries.

 

The logic for both is identical and the states menu works fine.  I get an error on the countries menu.

 

Here's the error

Notice: Undefined index country_id in C:\Sites\recycle_customer_update.php on line 450 selected="selected">

 

I can''t see why? Can someone tell me why one works and the other won't

 

Any help will greatly appreciated

 

 

 

This code for States dropdown list menu this part works fine

 

        <td>

          <select name="abbreviation" id="abbreviation" class="text_background">

          <option value="" <?php if (isset($error) && $_POST['abbreviation'] == $state) { echo 'selected="selected"';}

          elseif ($firstState == $state) {echo "selected=\"selected\"";} ?>>

          </option>

          <?php

          do { ?>

            <option value="<?php echo $row_GetStates['abbreviation']?>"<?php if (!(strcmp($row_GetStates['abbreviation'], $firstState)))

                {echo "selected=\"selected\"";} ?>><?php echo $row_GetStates['state_name']?>

            </option>

            <?php

            } while ($row_GetStates = mysql_fetch_assoc($GetStates));

              $rows = mysql_num_rows($GetStates);

              if($rows > 0) {

                mysql_data_seek($GetStates, 0);

        $row_GetStates = mysql_fetch_assoc($GetStates);

          }?>

          </select>

        </td>

 

 

 

Code for Countries dropdown list menu error in this section

 

        <td>

          <select name="country_id" id="country_id" class="text_background">

          <option value="" <?php if (isset($error) && $_POST['country_id'] == $country) { echo 'selected="selected"';} <<***ERROR HERE ***

          elseif ($firstCountry == $country) {echo "selected=\"selected\"";} ?>>

          </option>

          <?php

          do { ?>

            <option value="<?php echo $row_getCountry['country_id']?>"<?php if (!(strcmp($row_GetCountry['country_id'], $firstCountry)))

              {echo "selected=\"selected\"";} ?>><?php echo $row_GetCountry['name']?>

            </option>

            <?php

            } while ($row_getCountry = mysql_fetch_assoc($getCountry));

            $rows = mysql_num_rows($getCountry);

            if($rows > 0) {

              mysql_data_seek($getCountry, 0);

      $row_getCountry = mysql_fetch_assoc($getCountry);

          }?>

        </select>

      </td>

 

[ code ] tags are your friends

 

        <td>
          <select name="country_id" id="country_id" class="text_background">
          <option value="" <?php if (isset($error) && isset($_POST['country_id'] && $_POST['country_id'] == $country) { echo 'selected="selected"';} 
          elseif ($firstCountry == $country) {echo "selected=\"selected\"";} ?>>
          </option>
          <?php
          do { ?>
            <option value="<?php echo $row_getCountry['country_id']?>"<?php if (!(strcmp($row_GetCountry['country_id'], $firstCountry)))
               {echo "selected=\"selected\"";} ?>><?php echo $row_GetCountry['name']?>
            </option>
            <?php
            } while ($row_getCountry = mysql_fetch_assoc($getCountry));
             $rows = mysql_num_rows($getCountry);
             if($rows > 0) {
               mysql_data_seek($getCountry, 0);
          $row_getCountry = mysql_fetch_assoc($getCountry);
          }?>
         </select>
       </td>

 

Should take care of the error.

Thanks Frost, that worked.  Question though, why did'nt I get the same error for the states menu?  That's what confuses me, I thought about maybe needing an isset() but figured nah, states works ok without it, must be something else.

 

Thanks again

 

 

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.