Is there anything wrong with this *Missing Record ID*

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Seanie
    Member
    • Jun 2003
    • 98

    Is there anything wrong with this *Missing Record ID*

    Im trying to fix this code so it edits the content of a database, but it just keeps giving me 'Missing Record ID'

    The annoying thing is the very same code works for other sections of my site so I cannot understand why it does it for this table.

    PHP Code:
    <?php
        $id 
    $_GET['id'];
        include(
    '../includes/config.php');
        include(
    '../includes/functions.php');
        
        
    //form not yet submitted
        //display form, pre-filled with news to edit
        
    if (!$_POST['submit'])
        {
            
    //check for record id
            
    if ((!isset($_GET['id']) || trim($_GET['id']) == ''))
            {
            die (
    'Missing Record ID');
            }
            else
                
            
    //open a connection to the database
            
    $db mysql_connect($hostname$user$pass) or die ('Error connecting to mysql');
            
    mysql_select_db($name) or die ('Error connecting to mysql');
            
            
    //generate and execute the sql query
            
    $query "SELECT * FROM $act_hist WHERE id = '$id'";
            
    $result mysql_query($query)
            or die (
    "Error in query: $query. " mysql_error());
            
            
    //if a result is returned
            
    if (mysql_num_rows($result) > 0)
            {
                
    //turn it into an object
                
    $row mysql_fetch_object($result);
                
                
    //print form with the values that can be edited
            
    ?>
    <form name="edit_acthist" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <table width="600" border="0" cellspacing="1" cellpadding="2">
      <tr>
        <td align="right" valign="top" nowrap><strong>Act</strong></td>
        <td align="left" valign="top" nowrap>
          <input name="act_name1" type="text" id="act_name1" value="<?php echo $row->act_name?>">    </td>
        <td align="left" valign="top" nowrap> </td>
      </tr>
      <tr>
        <td align="right" valign="top" nowrap><strong>Singles</strong></td>
        <td align="left" valign="top" nowrap><textarea name="singles1" cols="50" rows="20" id="singles1"><?php echo $row->singles?></textarea></td>
        <td align="left" valign="top" nowrap><p>html table</p>
          <p>&lt;br /&gt; (line break) </p></td>
      </tr>
      <tr>
        <td align="right" valign="top" nowrap="nowrap"><strong>Albums</strong></td>
        <td align="left" valign="top" nowrap="nowrap"><textarea name="albums1" cols="50" rows="20" id="albums1"><?php echo $row->albums?></textarea></td>
        <td align="left" valign="top" nowrap="nowrap">html table</td>
      </tr>
      <tr>
        <td align="right" valign="top" nowrap><input name="ud_id" type="hidden" value="<?php echo $id?>" /></td>
        <td align="left" valign="top" nowrap><input type="submit" name="Submit" value="Submit">
          <input name="reset" type="reset" id="reset" value="Reset"></td>
        <td align="left" valign="top" nowrap>&nbsp;</td>
      </tr>
    </table>
    </form>
    <?php
        
    }
        
    //No Results Generated
        //Print an error mesage
        
    else
        {
            echo 
    '<font size="-1">That record could not be found..</font>';
        }
    }
    else
    {
        
    //form is submitted
        //start processing
        
        //open a connection to the database
        
    $db mysql_connect($hostname$user$pass) or die ('Error connecting to mysql');
        
    mysql_select_db($name) or die ('Error connecting to mysql');
        
        
    //generate query
        
    $update "UPDATE $act_hist SET act_name = '$act_name1', singles = '$singles1', albums = 'albums1' WHERE id = '$ud_id'";    
        
    $result mysql_query($update)
        or die (
    "Error in query: $update. " mysql_error());
                
        
    //print the result
        
    echo '<font size="-1">Update has been successful.<br/><br/>';
        echo 
    '<a href="archive_edit_acthist.php">Go back to acts...</a></font>';
        
        
    //close the connection
        
    mysql_close($db);        
    }
    ?>
    thanks for any advice
  • Lats
    Senior Member
    • Mar 2002
    • 3671

    #2
    I would suggest changing the red bit in this line...
    Code:
        <td align="right" valign="top" nowrap><input name="[COLOR=red]ud_id[/COLOR]" type="hidden" value="<?php echo $id; ?>" /></td>
    to...
    Code:
        <td align="right" valign="top" nowrap><input name="[COLOR=red]id[/COLOR]" type="hidden" value="<?php echo $id; ?>" /></td>
    Then your $_GET will be looking for the right item.

    Also, under your first else, there isn't an expected left brace ( { ).
    Lats...

    Comment

    widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
    Working...