pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

PHP paste-bin - collaborative debugging tool View Help


Posted by mypapit on Fri 29th Dec 19:47 (modification of post by Anonymous view diff)
diff | download | new post

  1. if(count($_POST)>0 && $submit=="Save"){
  2. //### ( HELP CODE HERE )###
  3. if (mysql_num_rows(mysql_query("select * from bmbi where english='$_POST[english]'"))>0){
  4. $msg.="My error msg here";
  5. }       
  6. if(!$msg){
  7. //### ( HELP CODE HERE )###
  8. if($HTTP_SERVER_VARS[HTTP_X_FORWARDED_FOR]!="") $ip=$HTTP_SERVER_VARS[HTTP_X_FORWARDED_FOR]; else $ip=$REMOTE_ADDR;
  9. $query="insert into bmbi(uid,melayu,english,datereg,ipaddr)values('$userid','$melayu','$english',".time().",'$ip')";
  10. mysql_query($query) or die("Query failed : " . mysql_error());
  11.  
  12.  
  13. //## 1) here i have 2 form. which name called melayu & english!
  14. //## 2) when user add melayu & english the data will insert to db
  15. //## 3) when user add melayu & english again with same data the db will denied.
  16. //## 4) here i want to create an error code while ITEM NO 3*
  17.  
  18.  
  19. //
  20. // return true = no duplicate
  21. // return false = duplicate detected :p
  22. //
  23.  
  24. function checkDuplicate($english, $english)
  25. {
  26.        
  27.         $differ = $time-1800;
  28.        
  29.         $sql = "SELECT melayu,english FROM bmbi WHERE english='$english' and melayu='$melayu'";
  30.         $result = mysql_query($sql);
  31.        
  32.         if (!$result) {
  33.                 $error = 'Database error: query failed !'
  34.                         . mysql_error();
  35.                 echo $error;
  36.                 logError($error);
  37.         }
  38.        
  39.         return(mysql_numrows($result)>0);
  40.  
  41. }

Submit a correction or amendment below. (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Use syntax highlighting

To highlight particular lines, prefix each line with @@


Remember my settings