Help Me Please

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Help Me Please

    hello experts i try to make a code but its not working i make a grabber of sms and i want that all the sms in this page simply copy on my own server and i try a code which not working please fix this code errors
    PHP Code:
    { 
        
    $match_name = preg_match('/<div class="smstext">(.*)<\/div>/i', $chunk[$i], $w); 



    $sms=$w[1];


    $name= var_export(substr($sms, 0, 20), true).PHP_EOL;
    $name=str_replace('\'','',$name);

    $myFile = "sms/".$name.".txt";
    $fh = fopen($myFile, 'w') or die("can't open file");
    $stringData = "".$sms."-\n";
    fwrite($fh, $stringData);
    fclose($fh);

     } 
    please help me

    #2
    debug it to find your error eg:
    PHP Code:
    {  
        
    $match_name = preg_match('/<div class="smstext">(.*)<\/div>/i', $chunk[$i], $w);  

    $sms=$w[1]; 
    print 
    "Debug1: ".$sms."<br/>";

    $name= var_export(substr($sms, 0, 20), true).PHP_EOL; 
    print 
    "Debug2: ".$name."<br/>";
    $name=str_replace('\'','',$name); 
    print 
    "Debug3: ".$name."<br/>"; //etc
    $myFile = "sms/".$name.".txt"; 
    $fh = fopen($myFile, 'w') or die("can't open file"); 
    $stringData = "".$sms."-\n"; 
    fwrite($fh, $stringData); 
    fclose($fh); 

     } 

    Comment


      #3
      ok i will another method

      Originally posted by something else View Post
      debug it to find your error eg:
      PHP Code:
      {  
          
      $match_name = preg_match('/<div class="smstext">(.*)<\/div>/i', $chunk[$i], $w);  

      $sms=$w[1]; 
      print 
      "Debug1: ".$sms."<br/>";

      $name= var_export(substr($sms, 0, 20), true).PHP_EOL; 
      print 
      "Debug2: ".$name."<br/>";
      $name=str_replace('\'','',$name); 
      print 
      "Debug3: ".$name."<br/>"; //etc
      $myFile = "sms/".$name.".txt"; 
      $fh = fopen($myFile, 'w') or die("can't open file"); 
      $stringData = "".$sms."-\n"; 
      fwrite($fh, $stringData); 
      fclose($fh); 

       } 
      hello sir please make this again because its not working fine it code not make no one files

      Added after 5 minutes:

      hello sir i have another option to make files can we paste the all lines according to us for ex :
      if lines are
      i am the best
      i am the bad
      i am the king
      i am the poor
      matlab je sabhi files wo mere according rakhe means agar main 1 hi paste krana chata hun to 1 paste ho aur agar 2 to 2
      is code meain kujh ho sakta hai ese
      PHP Code:
      $chunk = explode('<td class="pl10">', $page); 
      //print_r($chunk); 
      $count = count($chunk); 
      for (
      $i=1; $i < $count; $i++)  
      {   
          
      $match_name = preg_match('/<div class="smstext">(.*)<\/div>/i', $chunk, $w);   

      echo 
      $w[1]; 
      echo
      "<br />
      "
      ;
      echo 
      $w[2];echo"<br />
      "
      ;
      echo 
      $w[3];echo"<br />
      "
      ;
      echo 
      $w[4];echo"<br />
      "
      ;
      echo 
      $w[5];
      echo 
      $w[6];

       } 
      Last edited by Lue_chin; 11.04.12, 14:41.

      Comment


        #4
        sorry i cant understand what you want maybe something like:
        PHP Code:
        $chunk = explode('<td class="pl10">', $page);     
        for (
        $i=1; $i < count($chunk); $i++)   
        {    
            
        preg_match('/<div class="smstext">(.*)<\/div>/i', $chunk[$i], $w);   
            for (
        $a=0; $a < count($w); $a++)   
            { 
                echo 
        $w[$a]."<br />"; 
            }
         } 
        Last edited by something else; 12.04.12, 01:05.

        Comment


          #5
          Originally posted by something else View Post
          sorry i cant understand what you want maybe something like:
          PHP Code:
          $chunk = explode('<td class="pl10">', $page);     
          for (
          $i=1; $i < count($chunk); $i++)   
          {    
              
          preg_match('/<div class="smstext">(.*)<\/div>/i', $chunk[$i], $w);   
              for (
          $a=0; $a < count($w); $a++)   
              { 
                  echo 
          $w[$a]."<br />"; 
              }
           } 
          i explain what i want
          i want that there is 10 lines which i pick but i want to show only 5 or 6 files and its with another location means 1 lines place to 5th and 3 to 1st this type so i want to arrange all files according to me and this method i make text files in my server

          Comment


            #6
            then you would change the variables on this line:
            PHP Code:
            for ($a=0; $a < count($w); $a++) 
            to what ever you wanted eg: lines 3 to 5 would be:
            PHP Code:
             for ($a=3; $a < 6; $a++) 
            if you didnt want line 4 included in that then you would use a simple "if" statement eg:
            PHP Code:
            for ($a=3; $a < 6; $a++)    
                {  
                    if(
            $a!=4)
                    echo 
            $w[$a]."<br />";  
                } 

            Comment

            Working...
            X