I have a Problem with MySQL update. The code below is working but i want to block that others try to enter Data at Field "stat开发者_JAVA百科us" again.
How can i write the command for that?
if(isset($_GET['up']))
{
  if(strlen($_GET['up'])==71)
  {
    db_conn();
    $raw = explode(":",$_GET['up']);
    $sql = "UPDATE ".$database_table." SET status='".$raw[1]."',upl_time='".time()."' WHERE hash='".$raw[0]."' LIMIT 1";
    if(mysql_query($sql))
    {
    print "ACK";
    } 
    else
    print "NACK";
  }
  exit;
}
There are a couple of ways to do so:
- Add a field - - IS_UPDATED- to your table to maintain some sort of a flag that defaults to FALSE. Then in your query that updates the- statusfield, also set- IS_UPDATEDto TRUE. Also, in the update query, add this condition to the where clause -- IS_UPDATED = FALSE. This will mean that the- statuscolumn will only update if it has not already been updated.
- If the field - upl_timeis originally NULL or empty, and is only updated in the above query, when the- statuscolumn is updated, I think you can as well use this column instead of adding a new one. But this is better known by you.
- I'm not sure what's the origin of the update query from your application. But if possible, you might also consider adding logic to your application to disable the UPDATE altogether. 
I'd prefer approach 1.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论