Need some help with my script

Discussion in 'PHP' started by livewirerules, Oct 9, 2007.

  1. #1
    i have some problems with my php script

    Update and retrieve problem.
    The following code is to edit a movie detail form.the problem is first when i click edit it displays the current available data in the input text fields.But none of the details are displayed in the text area.
    when i enter the new values for the fields to update,i get the success message but none of the info are updated in the database.can someone pls help me to fix this.

    <?php include("adminnav.html"); ?>					
    		<div id="main">				
    			
    			<a name="TemplateInfo"></a>
    			<h1>Edit movie </h1>
    				
    			<p><strong>Edit movies </strong></p>
    			<?php echo $title; ?>
    			
    			</p>
    			<form action="editmovie.php" method="post" id="form1">
                  <p>Title&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      <input name="title" type="text" id="title" value="<?php echo $title; ?>"size="40" />
                  </p>
    			  <p>Director&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      <input name="director" type="text" id="director" value="<?php echo $director; ?>"size="40" />
                  </p>
    			  <p>Writer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      <input name="writer" type="text" id="writer" value="<?php echo $writer; ?>" size="40" />
                  </p>
    			  <p>Image &nbsp;&nbsp;&nbsp;&nbsp;
                      <?php $image_html ?>
                  </p>
    			  <p>Release date&nbsp;&nbsp;
                      <input name="date" type="text" id="date" value="<?php echo $release; ?>" size="20" />
                  </p>
    			  <p>Cast&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      <input name="cast" cols="40"  rows="5" id="cast" value="<?php echo $cast; ?>" />
                  </p>
    			  <p>Plot&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      <textarea name="plot" cols="40" rows="3" id="plot" value="<?php echo $plot; ?>"></textarea>
                  </p>
    			  <p>Other Info&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                      <textarea name="otherinfo" cols="40" rows="5" id="otherinfo" value="<?php echo $otherinfo; ?>"></textarea>
    			  Download links </p>
    			  <p>
    		         
    		          <textarea name="textarea" cols="40" rows="5" id="textarea" value="<?php echo $links; ?>"></textarea>
    		      </p>
    			  <p>
                    <input type="submit" name="editmovie" value="Edit it" />
                    <input type="reset" name="Submit2" value="Reset" />
                  </p>
    		  </form>
    			<h3>&nbsp;</h3>
    				
      </div>
     <?php
     if (isset($_POST['editmovie'])) {
    	
    	$sql="UPDATE `movie_info`SET 
    				id='',			
    				title='$_POST[title]',
    				director='$_POST[director]',
    				writer='$_POST[writer]',
    				image='',
    				date='$_POST[date]',
    				cast='$_POST[cast]',
    				plot='$_POST[plot]',
    				otherinfo='$_POST[otherinfo]'
     				WHERE id='$id'";
    	
    	$result=mysql_query($sql)or die(mysql_error());
    	
    	echo "Success";
    	
    	header("refresh:3;url=manage_movies.php");
    	
    	exit();
    
    }
    ?>	
    PHP:
     
    livewirerules, Oct 9, 2007 IP
  2. it career

    it career Notable Member

    Messages:
    3,562
    Likes Received:
    155
    Best Answers:
    0
    Trophy Points:
    270
    #2
    Try to run the sql query manually, may be no such entry exists in the database which corresponds to id.
     
    it career, Oct 9, 2007 IP
  3. Ned

    Ned Active Member

    Messages:
    402
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    78
    #3
    <textarea name="otherinfo" cols="40" rows="5" id="otherinfo" value="<?php echo $otherinfo; ?>"></textarea>
    Code (markup):
    should be

    
    <textarea name="otherinfo" cols="40" rows="5" id="otherinfo"><?php echo $otherinfo; ?></textarea>
    
    Code (markup):
    same for the other one.

    The textarea html tag doesn't use value=""
     
    Ned, Oct 9, 2007 IP
  4. livewirerules

    livewirerules Active Member

    Messages:
    276
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    58
    #4
    Ned,
    Thanks man that worked out :D
     
    livewirerules, Oct 9, 2007 IP