jim.davidson Posted June 5, 2007 Share Posted June 5, 2007 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> Quote Link to comment https://forums.phpfreaks.com/topic/54328-i-cant-find-the-error-need-another-set-of-eyees-to-see-it/ Share on other sites More sharing options...
per1os Posted June 5, 2007 Share Posted June 5, 2007 [ 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. Quote Link to comment https://forums.phpfreaks.com/topic/54328-i-cant-find-the-error-need-another-set-of-eyees-to-see-it/#findComment-268678 Share on other sites More sharing options...
jim.davidson Posted June 5, 2007 Author Share Posted June 5, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/54328-i-cant-find-the-error-need-another-set-of-eyees-to-see-it/#findComment-268694 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.