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
https://forums.phpfreaks.com/topic/259745-update-record-help/
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
https://forums.phpfreaks.com/topic/259745-update-record-help/#findComment-1331234
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.