Jump to content

$php_mysql$

Members
  • Posts

    391
  • Joined

  • Last visited

    Never

Posts posted by $php_mysql$

  1. friends whats wrong with this piece of code that one user on my site spams the same thing over and over tho i have added flood control for 6hours but he posts right after posting one. i have tested myself it works for me but why not for that user?

     

    
            if($_SESSION['last_session_request'] > time() - 21600){
        		        header("location: antiflood.php?post=wait");
        		        exit;
    		}	
    		$_SESSION['last_session_request'] = time();		
    

  2. i got that but why is it not executing my sql query? no matter what ever numeric value i input i get it printed by using print_r(); func but when i use $id = $_POST['id']; nothing prints

     

    <?php
    include 'db.php';
    
    print_r($_POST['id']);
    
    if(isset($_POST['submit'])){
    
                $id = $_POST['id']; // The $id is not effecting the sql query WHERE id='".$id."'
    
        	    $sql="SELECT `id`, `image` FROM `tbl` WHERE id='".$id."'";
    		$result = mysql_query($sql);
    		if(!$result){
    
    		}else{
    		while($row = mysql_fetch_array($result)){
    		if (mysql_num_rows($result)) {
    		$id = $row['id'];
    		if(!unlink($row['image'])){
    
    			}
    		}
    		$sql="DELETE FROM tbl WHERE id = '".$id."'";
    		$result= mysql_query($sql);
    		if(!$result){
    
    		}
    		}
    		}
    }
    ?>
    
    <form action="delete.php" method="POST">
    <input type="text" name="id">
    <input type="submit" value="Delete">
    </form>
    

  3. Hey all whats wrong when i hit submit the numeric value which i enter is not being sent to act=delete

     

    <?php
    include 'db.php';
    $act = $_GET["act"];
    $id=$_GET["id"];
    
    echo '<form action="delete.php?act=delete" method="post">';
    echo '<input type="text" name="del">';
    echo '<input type="submit" value="Delete">';
    echo '</form>';
    
    if($act=='delete'){
                $id = $_GET['del']; 
    	    $sql="SELECT `id`, `image` FROM `tbl` WHERE id='".$id."'";
    		$result = mysql_query($sql);
    		if(!$result){
    		echo 'SELECT failed: '.mysql_error();
    		}else{
    		while($row = mysql_fetch_array($result)){
    		if (mysql_num_rows($result)) {
    		$id = $row['id'];
    		if(!unlink($row['image'])){
    		echo "unlink ".$row['image']." failed";
    			}
    		}
    		$sql="DELETE FROM tbl WHERE id = '".$id."'";
    		$result= mysql_query($sql);
    		if(!$result){
    		echo 'DELETE from tbl with id '.$id.' failed: '.mysql_error();
    		}
    		}
    		}
    }
    ?>
    

  4. friends this function creates keywords but i am having a issue, if there is a link on my string then the output that this function gives is like:

     

    httpwwwsomesitecomdetailsphpid123456

     

    now how to make it that if it finds any http://www.somesite.com/details.php?id=123456, www.somesite.com/details.php?id=123456 or somesite.com/details.php?id=123456 than it ignores the Hyperlink and do not show anything on the output. basically ignore any sort of hyperlinks.

     

     

    function metakeyword($string){
          $stopWords = array('i','a','about','an','and','are','as','at','be','by','com','de','en','for','from','how','in','is','it','la','of','on','or','that','the','this','to','was','what','when','where','who','will','with','und','the','www');
       
          $string = preg_replace('/\s\s+/i', ' ', $string); // replace whitespace
          $string = trim($string); // trim the string
          $string = preg_replace('/[^a-zA-Z0-9 -]/', '', $string); // only take alphanumerical characters, but keep the spaces and dashes too…
          $string = strtolower($string); // make it lowercase
       
          preg_match_all('/\b.*?\b/i', $string, $matchWords);
          $matchWords = $matchWords[0];
          
          foreach ( $matchWords as $key=>$item ) {
              if ( $item == '' || in_array(strtolower($item), $stopWords) || strlen($item) <= 3 ) {
                  unset($matchWords[$key]);
              }
          }   
          $wordCountArr = array();
          if ( is_array($matchWords) ) {
              foreach ( $matchWords as $key => $val ) {
                  $val = strtolower($val);
                  if ( isset($wordCountArr[$val]) ) {
                      $wordCountArr[$val]++;
                  } else {
                      $wordCountArr[$val] = 1;
                  }
              }
          }
          arsort($wordCountArr);
          $wordCountArr = array_slice($wordCountArr, 0, 15);
          return $wordCountArr;
    }
    

     

    Please help me out you genius people

    Thanks in advance.

  5. thanks soo much but its not taking any effect. my current htaccess file looks like this

     

    DirectoryIndex index.php
    ErrorDocument 404 http://www.site.com
    ErrorDocument 403 http://www.site.com
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^site\.com$ [NC]
    RewriteRule ^(.*)$ http://www.site.com/$1 [R=301,L]
    
    RewriteRule ^details/([a-zA-z0-9-]+)_([0-9]+)$ details.php?category=$1&id=$2 [NC,L]
    
    <IfModule mod_deflate.c>
      <FilesMatch "\.(css|x?html?|php)$">  
      SetOutputFilter DEFLATE
      </FilesMatch>
    </IfModule>
    
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType text/css A100
    ExpiresByType text/html A100
    </IfModule>
    
    
    
    
    
    

     

    i have got about 8 categories which looks like this category=animal, category=birds etc etc and details are shown according to category like category=birds&id=23

  6. maybe i did it wrong, is this what u asked me to do?

     

    /////////////////////////////////////SQL Execution     

        function executeSql($sql){

            $conn = db_connect();         

            $result = mysql_query($sql, $conn)

                          or die(mysql_error($conn));

            return $result;     

        }

    if (executeSql($sql)) {

        $inserted_id = mysql_insert_id();

        var_dump($inserted_id);

    }

  7. hey mate, yes im planing to add the email function within the insert function. once user post is inserted it should imdtly send out an email with link to the post and to the email which the user posted in form.

     

    i tried it like this to get the id

     

    ///////////////////////////////////Insert		
    function insert($postData) {		
    $postData['description'] = clean($postData['description']);	
    if(!ifEmailExists($postData['email'])){
    $sql = " INSERT INTO tbl__emails SET
    		email = '".$postData['email']."',
    		postersname	= '".$postData['postersname']."',
    		phone	= '".$postData['phone']."'
    		";
    		executeSql($sql);
    }		
    if(empty($_FILES['image']["name"])){						
    		$sql = " INSERT INTO tbl SET
    		title	= '".$postData['title']."',
    		image	= '',
    		postersname	= '".$postData['postersname']."',
    		category 	= '".$postData['category']."',
    		type	= '".$postData['type']."',
    		state	= '".$postData['state']."',
    		location	= '".$postData['location']."',
    		email 	= '".$postData['email']."',
    		phone	= '".$postData['phone']."',
    		description	= '".$postData['description']."',
    		time	= '".time()."'
    		";
    		executeSql($sql);
    		$inserted_id = mysql_insert_id();
    		echo $inserted_id;
    		/*Here ill add the email function with the link once i get the id*/
    }else{			
    		global $uploadPath;
    		$remove_symbols = array('+', '=', '-', '{', '}', '$', '(', ')','&');
    		$removed_symbols = str_replace($remove_symbols, "_", $_FILES['image']['name']);  
    		$randomnum=rand(00000000,99999999);  
    		$imagepath = uploadFile($_FILES['image'], $uploadPath);
    		$image = new SimpleImage();
    		$image->load($imagepath);
    		$image->resize(250,280);
    		$resize_rename = $uploadPath.$randomnum._.$removed_symbols;
    		$image->save($resize_rename);									
    		unlink($imagepath); //delete the original file						
    		$sql = " INSERT INTO tbl SET
    		title	= '".$postData['title']."',
    		image	= '".$resize_rename."',
    		postersname	= '".$postData['postersname']."',
    		category 	= '".$postData['category']."',
    		type	= '".$postData['type']."',
    		state	= '".$postData['state']."',
    		location	= '".$postData['location']."',
    		email 	= '".$postData['email']."',
    		phone	= '".$postData['phone']."',
    		description	= '".$postData['description']."',
    		time	= '".time()."'
    		";
    		executeSql($sql);	
    		$inserted_id = mysql_insert_id();				
    		echo $inserted_id;	
    		/*Here ill add the email function with the link once i get the id*/
    		}
    }
    

     

    and my executeSql function  is

     

        function executeSql($sql){
            $conn = db_connect();          
            $result = mysql_query($sql, $conn)
                          or die(mysql_error($conn));
            return $result;       
        }
    

×
×
  • 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.