Jump to content

Update Record Help


bigfuzz

Recommended Posts

I'm having an issue updating a records. The insert and delete functions are working fine.

The $submit variable is being passed 'Update' ~ that is working.

This is some extremely old code that has migrated to a new server and is no longer working.

 

<?php
   $id = $_GET["id"];
   $delete = $_GET["submit"];
   $sortorder = $_POST["sortorder"];
   $name = $_POST["name"];
   $content = $_POST["content"];
   $submit = $_POST["submit"];
   
   require'../include/maindb.php';
   if($submit=="Submit") {
      $sql="INSERT INTO biography (id, sortorder, name, content) VALUES (NULL, '".$sortorder."', '".nl2br(addslashes(trim($name)))."', '".htmlentities(addslashes(trim($content)))."')";
   }
   if ($submit == "Update") {
      	$sql="UPDATE biography SET sortorder='".$sortorder."', name='".nl2br(addslashes(trim($name)))."', content='".htmlentities(addslashes(trim($content)))."' WHERE id='".$id."'";
   }
   if ($delete=="Delete") {
      $sql="DELETE FROM biography WHERE id='".$id."'";
   }
   mysql_query($sql);
   echo(mysql_error());
   header('Location: index.php'); 

?>

 

Link to comment
Share on other sites

How come id and delete are GET variables? shouldnt they be POST

echo out the $id somewhere to make sure you are getting what you are expecting and

$sql=mysql_query("UPDATE biography SET sortorder='".$sortorder."', name='".nl2br(addslashes(trim($name)))."', content='".htmlentities(addslashes(trim($content)))."' WHERE id='".$id."'");

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.