Jump to content

Updateing Mysql in PHP


leequalls

Recommended Posts

I am trying to update the mysql data when someone logs in the code below will not update the database anyone have any suggestions. I do not get any error codes.

 

mysql_query("UPDATE DJ SET lastaccess='$datetime' WHERE username=$username");
mysql_query("UPDATE DJ SET ip_address='$ip' WHERE username=$username");

Link to comment
https://forums.phpfreaks.com/topic/160097-updateing-mysql-in-php/
Share on other sites

Here is a update script that I use for some stuff.

<?php
//error_reporting(E_ALL);
//ini_set('display_errors',1);
session_start();
require 'connection.php';
if(isset($_POST['submit']))
{
  $item_name = mysql_real_escape_string($_POST['item_name']);
  $description = mysql_real_escape_string($_POST['description']);
  $in_return = mysql_real_escape_string($_POST['in_return']);
  $idnumber = mysql_real_escape_string($_POST['id']);
   
  $sql = "UPDATE table_name_here SET item_name = '$item_name', description = '$description', in_return = '$in_return' WHERE id = '$idnumber'";
  if(mysql_query($sql))
  {
     $_SESSION['updatecomplete'] = "Update Complete!";
 header("location: http://www.--------.com/-------.php");
 exit();
  }
  else
  {
     $_SESSION['updateerror'] = "Error. Please try again later.";
 header("location: http://www.------.com/------.php");
 exit();
  }
}
?>

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.