leequalls Posted May 29, 2009 Share Posted May 29, 2009 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"); Quote Link to comment Share on other sites More sharing options...
Michdd Posted May 29, 2009 Share Posted May 29, 2009 mysql_query("UPDATE `DJ` SET lastaccess='$datetime', ip_address='$ip' WHERE username='$username'"); Needed to put '' around $username, also only one query needed. Quote Link to comment Share on other sites More sharing options...
justAnoob Posted May 29, 2009 Share Posted May 29, 2009 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(); } } ?> Quote Link to comment Share on other sites More sharing options...
leequalls Posted May 29, 2009 Author Share Posted May 29, 2009 mysql_query("UPDATE `DJ` SET lastaccess='$datetime', ip_address='$ip' WHERE username='$username'"); Needed to put '' around $username, also only one query needed. Thanks This fixed the problem just needed the "$username" Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.