Want more features on Pastebin? Sign Up, it's FREE!
Guest

insert into mysql problem

By: a guest on Feb 26th, 2012  |  syntax: None  |  size: 0.71 KB  |  views: 23  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. $connect= mysql_connect("localhost","root") or die ("Sorry, Can not connect to database");
  2.  
  3. mysql_select_db("login") or die (mysql_error());
  4.  
  5. $user=$_POST['staff'];
  6. echo $user;
  7.  
  8. $query="SELECT  * from users where username='$user' ";
  9. $result=mysql_query($query,$connect) or die(mysql_error());
  10. $row=mysql_fetch_array($result);
  11.  
  12. $uid=$row['userid'];
  13. echo $uid;
  14.  
  15. $query="SELECT  * from opt where userid='$uid' ";
  16. $result=mysql_query($query,$connect) or die(mysql_error());
  17. $row=mysql_fetch_array($result);
  18.  
  19. if($row['confirm']==0)
  20. {
  21.  
  22. $query = "INSERT INTO opt (confirm) values(1)";
  23. echo 'The user selected options has confirmed';
  24.  
  25.  
  26. }
  27. ?>
  28.        
  29. mysql_query($query);
  30.        
  31. mysql_query($query);
  32.        
  33. $user = mysql_real_escape_string($user);
clone this paste RAW Paste Data