Page 2 of 2

Re: rename values in dropdown box

Posted: Mon May 04, 2009 9:18 pm
by angelic_devil
ok i corrected the errors u mentioned but its still not executing the the code its only refreshing the page

Code: Select all

 
<?php require_once("d:/wamp/www/php_stockphotos/includes/session.php"); ?>
<?php require_once("d:/wamp/www/php_stockphotos/includes/connection.php"); ?>
<?php require_once("d:/wamp/www/php_stockphotos/includes/constants.php"); ?>
<body>
<?php
 
$genre_name = $_POST['genre'];
$genrename = 'genrename';
$genrevalue = array();
$genrename_list = array();
$genre_value = $_POST['genrename'];
 
$query_name = " SELECT image_category.genre FROM image_category ";
    $result = mysql_query($query_name);
    confirm_query($result);
    $genrename_list[]=" ";
 
  while ($record = mysql_fetch_assoc($result)) {
          $genrename_list[] = $record['genre'] ;
             
        }
       
?>
<?
 
 //-----------Rename genre in database ---------------------
 if (isset($_POST['rename_genre'])) {
 
 echo $genre_name;
 echo $genrename_list[$genre_value];
 if  ($genre_name!=""){
 $query = "UPDATE image_category
          SET image_category.genre = '$genre_name'
          WHERE image_category.genre = '{$genrename_list[$genre_value]}'";
$result1 = mysql_query($query);
 
    if ($result1) {
            $message = "new genre has been renamed";
             
        }
         else {
         $message = "new genre could not be renamed";
          }
}
 }
 
 else 
 { $message = " You have left the text box empty....enter valid name to rename the selected ";}
 
 ?> 
 
<td = "page"> 
<form action="rename.php" method="post">
<table>
 
<td><br>
<select name="genrename" maxlength="30">
 
        //-----------displays genre from database ---------------------
       
        <?php
       
        // Loops through the $status_list array
         foreach ($genrename_list as $value => $option)
        {
            // Sets an attribute to show the chosen status as selected
            $selected = ($genre_value == $value) ? ' selected="selected"' : '';
                      
            // Builds an option for each acceptable status
           echo '<option value="'.$value.'"'.$selected.'>'.$option.'</option>';
           
        }
        ?>
   
 
 </select> </td>
<tr>
                    <td>Genre</td>
                    <td><input type="text" name="genre" maxlength="20" value="<?php echo htmlentities($genre_name); ?>" /></td>
                </tr>
 
<tr>
                    <td colspan="2"><input type="submit" name="rename_genre" value="rename_genre" /></td>
                </tr>
               
            </table>
 
</form>
 
</td> 
 
 
 
</body> 
 
 
 
 

Re: rename values in dropdown box

Posted: Mon May 04, 2009 9:40 pm
by McInfo
1. Fatal error: Call to undefined function confirm_query()

2. $message is never echoed.

3. Line 60: PHP comment in HTML

4. Line 53: fragmented HTML attribute and <td> not in table

5. Line 91: </td> not in table

6. session.php: undefined function redirect_to()

Edit: This post was recovered from search engine cache.

Re: rename values in dropdown box

Posted: Tue May 05, 2009 4:10 am
by angelic_devil
still not working

Code: Select all

 
<?php require_once("d:/wamp/www/php_stockphotos/includes/session.php"); ?>
<?php require_once("d:/wamp/www/php_stockphotos/includes/connection.php"); ?>
<?php require_once("d:/wamp/www/php_stockphotos/includes/functions.php"); ?>
 
<body>
<?php
 
$genre_name = $_POST['genre'];
$genrename = 'genrename';
$genrevalue = array();
$genrename_list = array();
$genre_value = $_POST['genrename'];
 
$query_name = " SELECT image_category.genre FROM image_category ";
    $result = mysql_query($query_name);
    confirm_query($result);
    $genrename_list[]=" ";
 
  while ($record = mysql_fetch_assoc($result)) {
          $genrename_list[] = $record['genre'] ;
             
        }
       
?>
<?
 
 //-----------Rename genre in database ---------------------
 if (isset($_POST['rename_genre'])) {
 
 echo $genre_name;
 echo $genrename_list[$genre_value];
 if  ($genre_name!=""){
 $query = "UPDATE image_category
          SET image_category.genre = '$genre_name'
          WHERE image_category.genre = '{$genrename_list[$genre_value]}'";
$result1 = mysql_query($query);
 
    if ($result1) {
            $message = "new genre has been renamed";
             
        }
         else {
         $message = "new genre could not be renamed";
          }
}
 }
 
 else 
 { $message = " You have left the text box empty....enter valid name to rename the selected ";}
 
 ?>
 
<?php if (!empty($message)) {echo "<p class=\"message\">" . $message . "</p>";} ?>
<form action="rename.php" method="post">
<table>
 
 
    <select name="genrename" maxlength="30">
 
 
 
        <?php
        //-----------displays genre from database ---------------------
       
        // Loops through the $status_list array
         foreach ($genrename_list as $value => $option)
        {
            // Sets an attribute to show the chosen status as selected
            $selected = ($genre_value == $value) ? ' selected="selected"' : '';
                      
            // Builds an option for each acceptable status
           echo '<option value="'.$value.'"'.$selected.'>'.$option.'</option>';
           
        }
        ?>
 
 
    </select>
    <td></td>
    <tr>
        <td>Genre</td>
        <td><input type="text" name="genre" maxlength="20"
            value="<?php echo htmlentities($genre_name);?>" /></td>
    </tr>
 
    <tr>
        <td colspan="2"><input type="submit" name="rename_genre"
            value="rename_genre" /></td>
    </tr>
 
</table>
 
</form>
 
</body>
 
 
 

Re: rename values in dropdown box

Posted: Tue May 05, 2009 10:29 am
by McInfo
Put this at the top of your script.

Code: Select all

<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
?>
Edit: This post was recovered from search engine cache.

Re: rename values in dropdown box

Posted: Tue May 05, 2009 2:29 pm
by angelic_devil
still it just refreshs the page however before and even now its only undefined index at line 9 index: genre and 13 index: genrename

its not doing anything else.

Re: rename values in dropdown box

Posted: Tue May 05, 2009 5:15 pm
by angelic_devil
ok i rewrote the whole script and got it to work

Re: rename values in dropdown box

Posted: Tue May 05, 2009 8:38 pm
by McInfo
Congratulations.

Edit: This post was recovered from search engine cache.