php - location: add ID to URL after update -


the following updates database record, once completed direct page view updated record.

header('location:view_resource.php?resource_id=$id'); 

i can't seem add records id url, comes as: view_resource.php?resource_id=$id

full code below:

 <?php     include('conn.php');      if(isset($_get['resource_id']))     {         $id=$_get['resource_id'];          if(isset($_post['submit']))         {             $name=$_post['name'];             $description=$_post['description'];             $query3=mysql_query("update z_resource set name='$name', description='$description' resource_id='$id'");              if($query3)             {                 header('location:view_resource.php?resource_id=$id');             }         }          $query1=mysql_query("select * z_resource resource_id='$id'");         $query2=mysql_fetch_array($query1);         ?>          <form method="post" action="">             name:<input type="text" name="name" value="<?php echo $query2['name']; ?>" /><br />             description:<input type="text" name="description" value="<?php echo $query2['description']; ?>" /><br />              <br />             <input type="submit" name="submit" value="update" />        </form>         <?php    } ?> 

thanks

change single quotes '' double 1 "" as

header('location:view_resource.php?resource_id=$id');        ^^                                         ^^ 

into

header("location:view_resource.php?resource_id=$id");        ^^                                         ^^ 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -